diff --git a/src/Drivers/Abstract/AbstractInputHandler.php b/src/Drivers/Abstract/AbstractInputHandler.php index faf90ad5..4fdbe951 100644 --- a/src/Drivers/Abstract/AbstractInputHandler.php +++ b/src/Drivers/Abstract/AbstractInputHandler.php @@ -6,8 +6,9 @@ use Intervention\Image\Drivers\Abstract\Decoders\AbstractDecoder; use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ImageInterface; +use Intervention\Image\Interfaces\InputHandlerInterface; -abstract class AbstractInputHandler +abstract class AbstractInputHandler implements InputHandlerInterface { /** * Array of decoders which will be stacked into to the input handler chain @@ -15,15 +16,25 @@ abstract class AbstractInputHandler protected array $decoders = []; /** - * Create new instance + * {@inheritdoc} * - * @param array $decoders + * @see InputHandlerInterface::__construct() */ public function __construct(array $decoders = []) { $this->decoders = count($decoders) ? $decoders : $this->decoders; } + /** + * {@inheritdoc} + * + * @see InputHandlerInterface::handle() + */ + public function handle($input): ImageInterface|ColorInterface + { + return $this->chain()->handle($input); + } + /** * Stack the decoder array into a nested decoder object * @@ -46,15 +57,4 @@ abstract class AbstractInputHandler return $chain; } - - /** - * Try to decode the given input with each decoder of the the handler chain - * - * @param mixed $input - * @return ImageInterface|ColorInterface - */ - public function handle($input): ImageInterface|ColorInterface - { - return $this->chain()->handle($input); - } } diff --git a/src/Interfaces/InputHandlerInterface.php b/src/Interfaces/InputHandlerInterface.php new file mode 100644 index 00000000..9112021f --- /dev/null +++ b/src/Interfaces/InputHandlerInterface.php @@ -0,0 +1,21 @@ +chain; + return $this->decoders[0]; } }; }