Upgrade to 3.8.0
This commit is contained in:
@@ -16,20 +16,15 @@ use Exception;
|
||||
*/
|
||||
class Darkroom
|
||||
{
|
||||
public static $types = [
|
||||
public static array $types = [
|
||||
'gd' => 'Kirby\Image\Darkroom\GdLib',
|
||||
'im' => 'Kirby\Image\Darkroom\ImageMagick'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $settings = [];
|
||||
protected array $settings = [];
|
||||
|
||||
/**
|
||||
* Darkroom constructor
|
||||
*
|
||||
* @param array $settings
|
||||
*/
|
||||
public function __construct(array $settings = [])
|
||||
{
|
||||
@@ -40,12 +35,9 @@ class Darkroom
|
||||
* Creates a new Darkroom instance for the given
|
||||
* type/driver
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $settings
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function factory(string $type, array $settings = [])
|
||||
public static function factory(string $type, array $settings = []): object
|
||||
{
|
||||
if (isset(static::$types[$type]) === false) {
|
||||
throw new Exception('Invalid Darkroom type');
|
||||
@@ -57,8 +49,6 @@ class Darkroom
|
||||
|
||||
/**
|
||||
* Returns the default thumb settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function defaults(): array
|
||||
{
|
||||
@@ -78,9 +68,6 @@ class Darkroom
|
||||
|
||||
/**
|
||||
* Normalizes all thumb options
|
||||
*
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
protected function options(array $options = []): array
|
||||
{
|
||||
@@ -108,9 +95,7 @@ class Darkroom
|
||||
unset($options['bw']);
|
||||
}
|
||||
|
||||
if ($options['quality'] === null) {
|
||||
$options['quality'] = $this->settings['quality'];
|
||||
}
|
||||
$options['quality'] ??= $this->settings['quality'];
|
||||
|
||||
return $options;
|
||||
}
|
||||
@@ -119,12 +104,8 @@ class Darkroom
|
||||
* Calculates the dimensions of the final thumb based
|
||||
* on the given options and returns a full array with
|
||||
* all the final options to be used for the image generator
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
public function preprocess(string $file, array $options = [])
|
||||
public function preprocess(string $file, array $options = []): array
|
||||
{
|
||||
$options = $this->options($options);
|
||||
$image = new Image($file);
|
||||
@@ -148,10 +129,6 @@ class Darkroom
|
||||
/**
|
||||
* This method must be replaced by the driver to run the
|
||||
* actual image processing job.
|
||||
*
|
||||
* @param string $file
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
public function process(string $file, array $options = []): array
|
||||
{
|
||||
|
Reference in New Issue
Block a user