From 8e00dd330ff8ef944492037c5dd17da00b85daa6 Mon Sep 17 00:00:00 2001 From: Adam Averay Date: Sat, 27 Apr 2024 00:29:43 +0900 Subject: [PATCH] Add ImageManager interface (#1336) --- src/ImageManager.php | 50 ++++------------- src/Interfaces/ImageManagerInterface.php | 68 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 40 deletions(-) create mode 100644 src/Interfaces/ImageManagerInterface.php diff --git a/src/ImageManager.php b/src/ImageManager.php index b9758339..383dea5f 100644 --- a/src/ImageManager.php +++ b/src/ImageManager.php @@ -4,14 +4,14 @@ namespace Intervention\Image; -use Intervention\Image\Exceptions\RuntimeException; use Intervention\Image\Interfaces\DriverInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Drivers\Gd\Driver as GdDriver; use Intervention\Image\Drivers\Imagick\Driver as ImagickDriver; use Intervention\Image\Interfaces\DecoderInterface; +use Intervention\Image\Interfaces\ImageManagerInterface; -final class ImageManager +final class ImageManager implements ImageManagerInterface { protected DriverInterface $driver; @@ -59,13 +59,9 @@ public static function imagick(): self } /** - * Create new image instance with given width & height + * {@inheritdoc} * - * @link https://image.intervention.io/v3/basics/instantiation#creating-new-images - * @param int $width - * @param int $height - * @throws RuntimeException - * @return ImageInterface + * @see ImageManagerInterface::create() */ public function create(int $width, int $height): ImageInterface { @@ -73,33 +69,9 @@ public function create(int $width, int $height): ImageInterface } /** - * Create new image instance from given input which can be one of the following + * {@inheritdoc} * - * - Path in filesystem - * - File Pointer resource - * - SplFileInfo object - * - Raw binary image data - * - Base64 encoded image data - * - Data Uri - * - Intervention\Image\Image Instance - * - * To decode the raw input data, you can optionally specify a decoding strategy - * with the second parameter. This can be an array of class names or objects - * of decoders to be processed in sequence. In this case, the input must be - * decodedable with one of the decoders passed. It is also possible to pass - * a single object or class name of a decoder. - * - * All decoders that implement the `DecoderInterface::class` can be passed. Usually - * a selection of classes of the namespace `Intervention\Image\Decoders` - * - * If the second parameter is not set, an attempt to decode the input is made - * with all available decoders of the driver. - * - * @link https://image.intervention.io/v3/basics/instantiation#reading-images - * @param mixed $input - * @param string|array|DecoderInterface $decoders - * @throws RuntimeException - * @return ImageInterface + * @see ImageManagerInterface::read() */ public function read(mixed $input, string|array|DecoderInterface $decoders = []): ImageInterface { @@ -113,11 +85,9 @@ public function read(mixed $input, string|array|DecoderInterface $decoders = []) } /** - * Create new animated image by given callback + * {@inheritdoc} * - * @link https://image.intervention.io/v3/basics/instantiation#creating-animations - * @param callable $init - * @return ImageInterface + * @see ImageManagerInterface::animate() */ public function animate(callable $init): ImageInterface { @@ -125,9 +95,9 @@ public function animate(callable $init): ImageInterface } /** - * Return currently used driver + * {@inheritdoc} * - * @return DriverInterface + * @see ImageManagerInterface::driver() */ public function driver(): DriverInterface { diff --git a/src/Interfaces/ImageManagerInterface.php b/src/Interfaces/ImageManagerInterface.php new file mode 100644 index 00000000..140b895d --- /dev/null +++ b/src/Interfaces/ImageManagerInterface.php @@ -0,0 +1,68 @@ +