From 9f885da391e345afc2bea48ec176bf07bc999cc7 Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 31 Oct 2021 07:55:33 +0100 Subject: [PATCH] Fill modifier filling --- src/Drivers/Gd/Modifiers/FillModifier.php | 11 ++++++++--- src/Drivers/Imagick/Modifiers/FillModifier.php | 12 +++++++++--- src/Traits/CanHandleInput.php | 11 ----------- 3 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 src/Traits/CanHandleInput.php diff --git a/src/Drivers/Gd/Modifiers/FillModifier.php b/src/Drivers/Gd/Modifiers/FillModifier.php index 2cf7fd54..c2eb41d8 100644 --- a/src/Drivers/Gd/Modifiers/FillModifier.php +++ b/src/Drivers/Gd/Modifiers/FillModifier.php @@ -6,11 +6,11 @@ use Intervention\Image\Drivers\Gd\InputHandler; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; -use Intervention\Image\Traits\CanHandleInput; +use Intervention\Image\Traits\CanResolveDriverClass; class FillModifier implements ModifierInterface { - use CanHandleInput; + use CanResolveDriverClass; public function __construct($filling, ?int $x = null, ?int $y = null) { @@ -21,7 +21,7 @@ class FillModifier implements ModifierInterface { $width = $image->getWidth(); $height = $image->getHeight(); - $filling = $this->handleInput($this->filling); + $filling = $this->getApplicableFilling(); foreach ($image as $frame) { imagefilledrectangle($frame->getCore(), 0, 0, $width - 1, $height - 1, $filling); @@ -29,4 +29,9 @@ class FillModifier implements ModifierInterface return $image; } + + protected function getApplicableFilling(): ColorInterface + { + return $this->resolveDriverClass('InputHandler')->handle($this->filling); + } } diff --git a/src/Drivers/Imagick/Modifiers/FillModifier.php b/src/Drivers/Imagick/Modifiers/FillModifier.php index 81e20cfd..fb4f35b5 100644 --- a/src/Drivers/Imagick/Modifiers/FillModifier.php +++ b/src/Drivers/Imagick/Modifiers/FillModifier.php @@ -4,13 +4,14 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers; use ImagickDraw; use Intervention\Image\Drivers\Imagick\InputHandler; +use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; -use Intervention\Image\Traits\CanHandleInput; +use Intervention\Image\Traits\CanResolveDriverClass; class FillModifier implements ModifierInterface { - use CanHandleInput; + use CanResolveDriverClass; public function __construct($filling, ?int $x = null, ?int $y = null) { @@ -19,7 +20,7 @@ class FillModifier implements ModifierInterface public function apply(ImageInterface $image): ImageInterface { - $filling = $this->handleInput($this->filling); + $filling = $this->getApplicableFilling(); $draw = new ImagickDraw(); $draw->setFillColor($filling->getPixel()); @@ -31,4 +32,9 @@ class FillModifier implements ModifierInterface return $image; } + + protected function getApplicableFilling(): ColorInterface + { + return $this->resolveDriverClass('InputHandler')->handle($this->filling); + } } diff --git a/src/Traits/CanHandleInput.php b/src/Traits/CanHandleInput.php deleted file mode 100644 index 3182e2af..00000000 --- a/src/Traits/CanHandleInput.php +++ /dev/null @@ -1,11 +0,0 @@ -handle($value); - } -}