diff --git a/src/Decoders/ColorObjectDecoder.php b/src/Decoders/ColorObjectDecoder.php index f81f7170..60480361 100644 --- a/src/Decoders/ColorObjectDecoder.php +++ b/src/Decoders/ColorObjectDecoder.php @@ -4,8 +4,24 @@ declare(strict_types=1); namespace Intervention\Image\Decoders; -use Intervention\Image\Drivers\SpecializableDecoder; +use Intervention\Image\Drivers\AbstractDecoder; +use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Interfaces\ColorInterface; +use Intervention\Image\Interfaces\ImageInterface; -class ColorObjectDecoder extends SpecializableDecoder +class ColorObjectDecoder extends AbstractDecoder { + /** + * {@inheritdoc} + * + * @see DecoderInterface::decode() + */ + public function decode(mixed $input): ImageInterface|ColorInterface + { + if (!is_a($input, ColorInterface::class)) { + throw new DecoderException('Unable to decode input'); + } + + return $input; + } } diff --git a/src/Decoders/ImageObjectDecoder.php b/src/Decoders/ImageObjectDecoder.php index ea01091c..2a98c2e8 100644 --- a/src/Decoders/ImageObjectDecoder.php +++ b/src/Decoders/ImageObjectDecoder.php @@ -4,8 +4,24 @@ declare(strict_types=1); namespace Intervention\Image\Decoders; -use Intervention\Image\Drivers\SpecializableDecoder; +use Intervention\Image\Drivers\AbstractDecoder; +use Intervention\Image\Exceptions\DecoderException; +use Intervention\Image\Interfaces\ImageInterface; +use Intervention\Image\Interfaces\ColorInterface; -class ImageObjectDecoder extends SpecializableDecoder +class ImageObjectDecoder extends AbstractDecoder { + /** + * {@inheritdoc} + * + * @see DecoderInterface::decode() + */ + public function decode(mixed $input): ImageInterface|ColorInterface + { + if (!is_a($input, ImageInterface::class)) { + throw new DecoderException('Unable to decode input'); + } + + return $input; + } } diff --git a/src/Drivers/Gd/Decoders/ColorObjectDecoder.php b/src/Drivers/Gd/Decoders/ColorObjectDecoder.php deleted file mode 100644 index 51abb3c0..00000000 --- a/src/Drivers/Gd/Decoders/ColorObjectDecoder.php +++ /dev/null @@ -1,22 +0,0 @@ -