Skip to content

Commit ca2b97c

Browse files
committed
Refactor code
1 parent f4ae97b commit ca2b97c

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/Drivers/Gd/Modifiers/FillModifier.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class FillModifier extends GenericFillModifier implements SpecializedInterface
2323
*/
2424
public function apply(ImageInterface $image): ImageInterface
2525
{
26-
$color = $this->color($image);
26+
$color = $this->driver()->colorProcessor($image)->colorToNative(
27+
$this->color()
28+
);
2729

2830
foreach ($image as $frame) {
2931
if ($this->hasPosition()) {
@@ -36,16 +38,6 @@ public function apply(ImageInterface $image): ImageInterface
3638
return $image;
3739
}
3840

39-
/**
40-
* @throws StateException
41-
*/
42-
private function color(ImageInterface $image): int
43-
{
44-
return $this->driver()->colorProcessor($image)->colorToNative(
45-
$this->driver()->handleColorInput($this->color)
46-
);
47-
}
48-
4941
/**
5042
* @throws ModifierException
5143
*/

src/Drivers/Imagick/Modifiers/FillModifier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class FillModifier extends ModifiersFillModifier implements SpecializedInterface
2323
public function apply(ImageInterface $image): ImageInterface
2424
{
2525
$pixel = $this->driver()->colorProcessor($image)->colorToNative(
26-
$this->driver()->handleColorInput($this->color)
26+
$this->color()
2727
);
2828

2929
foreach ($image->core()->native() as $frame) {

src/Modifiers/FillModifier.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Intervention\Image\Modifiers;
66

77
use Intervention\Image\Drivers\SpecializableModifier;
8+
use Intervention\Image\Interfaces\ColorInterface;
89
use Intervention\Image\Interfaces\PointInterface;
910

1011
class FillModifier extends SpecializableModifier
@@ -23,4 +24,12 @@ public function hasPosition(): bool
2324
{
2425
return $this->position instanceof PointInterface;
2526
}
27+
28+
/**
29+
* Return filling color object:
30+
*/
31+
protected function color(): ColorInterface
32+
{
33+
return $this->driver()->handleColorInput($this->color);
34+
}
2635
}

0 commit comments

Comments
 (0)