Upgrade to 3.4.3

This commit is contained in:
Bastian Allgeier
2020-09-15 10:25:09 +02:00
parent 54b9ba3047
commit d8e797dd9b
108 changed files with 1750 additions and 523 deletions

View File

@@ -23,11 +23,25 @@ class Darkroom
protected $settings = [];
/**
* Darkroom constructor
*
* @param array $settings
*/
public function __construct(array $settings = [])
{
$this->settings = array_merge($this->defaults(), $settings);
}
/**
* 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 = [])
{
if (isset(static::$types[$type]) === false) {
@@ -38,6 +52,11 @@ class Darkroom
return new $class($settings);
}
/**
* Returns the default thumb settings
*
* @return array
*/
protected function defaults(): array
{
return [
@@ -51,6 +70,12 @@ class Darkroom
];
}
/**
* Normalizes all thumb options
*
* @param array $options
* @return array
*/
protected function options(array $options = []): array
{
$options = array_merge($this->settings, $options);
@@ -84,6 +109,15 @@ class Darkroom
return $options;
}
/**
* 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 = [])
{
$options = $this->options($options);
@@ -96,6 +130,14 @@ class Darkroom
return $options;
}
/**
* 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
{
return $this->preprocess($file, $options);