From f24a33705815b7f48351d4a157795cb064d8747b Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Thu, 19 Oct 2023 17:51:20 +0200 Subject: [PATCH] Remove Cmyk Colors for now --- src/Colors/Cmyk/Channels/Cyan.php | 55 --------- src/Colors/Cmyk/Channels/Key.php | 8 -- src/Colors/Cmyk/Channels/Magenta.php | 8 -- src/Colors/Cmyk/Channels/Yellow.php | 8 -- src/Colors/Cmyk/Color.php | 116 ------------------ src/Colors/Cmyk/Colorspace.php | 38 ------ .../Cmyk/Decoders/StringColorDecoder.php | 37 ------ src/Colors/Rgb/Color.php | 7 -- src/Colors/Rgb/Colorspace.php | 11 -- src/Drivers/Gd/InputHandler.php | 10 +- src/Drivers/Imagick/InputHandler.php | 10 +- src/Interfaces/ColorInterface.php | 6 +- tests/Colors/Cmyk/ChannelTest.php | 48 -------- tests/Colors/Cmyk/ColorTest.php | 85 ------------- tests/Colors/Cmyk/ColorspaceTest.php | 26 ---- .../Cmyk/Decoders/StringColorDecoderTest.php | 35 ------ tests/Colors/Rgb/ColorTest.php | 34 ----- tests/Colors/Rgb/ColorspaceTest.php | 26 ---- tests/Drivers/Gd/InputHandlerTest.php | 18 +-- tests/Drivers/Imagick/InputHandlerTest.php | 18 +-- tests/TestCase.php | 4 +- 21 files changed, 30 insertions(+), 578 deletions(-) delete mode 100644 src/Colors/Cmyk/Channels/Cyan.php delete mode 100644 src/Colors/Cmyk/Channels/Key.php delete mode 100644 src/Colors/Cmyk/Channels/Magenta.php delete mode 100644 src/Colors/Cmyk/Channels/Yellow.php delete mode 100644 src/Colors/Cmyk/Color.php delete mode 100644 src/Colors/Cmyk/Colorspace.php delete mode 100644 src/Colors/Cmyk/Decoders/StringColorDecoder.php delete mode 100644 tests/Colors/Cmyk/ChannelTest.php delete mode 100644 tests/Colors/Cmyk/ColorTest.php delete mode 100644 tests/Colors/Cmyk/ColorspaceTest.php delete mode 100644 tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php delete mode 100644 tests/Colors/Rgb/ColorspaceTest.php diff --git a/src/Colors/Cmyk/Channels/Cyan.php b/src/Colors/Cmyk/Channels/Cyan.php deleted file mode 100644 index 213fea38..00000000 --- a/src/Colors/Cmyk/Channels/Cyan.php +++ /dev/null @@ -1,55 +0,0 @@ -value = $this->validate($value); - } - - public function value(): int - { - return $this->value; - } - - public function normalize($precision = 32): float - { - return round($this->value() / $this->max(), $precision); - } - - public function min(): int - { - return 0; - } - - public function max(): int - { - return 100; - } - - public function validate(mixed $value): mixed - { - if ($value < $this->min() || $value > $this->max()) { - throw new ColorException('CMYK color values must be in range 0-100.'); - } - - return $value; - } - - public function toString(): string - { - return (string) $this->value(); - } - - public function __toString(): string - { - return $this->toString(); - } -} diff --git a/src/Colors/Cmyk/Channels/Key.php b/src/Colors/Cmyk/Channels/Key.php deleted file mode 100644 index 2893d2af..00000000 --- a/src/Colors/Cmyk/Channels/Key.php +++ /dev/null @@ -1,8 +0,0 @@ -channels = [ - new Cyan($c), - new Magenta($m), - new Yellow($y), - new Key($k), - ]; - } - - public function toHex(): string - { - return $this->toRgb()->toHex(); - } - - public function channels(): array - { - return $this->channels; - } - - public function cyan(): Cyan - { - return $this->channel(Cyan::class); - } - - public function magenta(): Magenta - { - return $this->channel(Magenta::class); - } - - public function yellow(): Yellow - { - return $this->channel(Yellow::class); - } - - public function key(): Key - { - return $this->channel(Key::class); - } - - public function toArray(): array - { - return [ - $this->cyan()->value(), - $this->magenta()->value(), - $this->yellow()->value(), - $this->key()->value(), - ]; - } - - public function convertTo(string|ColorspaceInterface $colorspace): ColorInterface - { - $colorspace = match (true) { - is_object($colorspace) => $colorspace, - default => new $colorspace(), - }; - - return $colorspace->convertColor($this); - } - - public function toRgb(): RgbColor - { - return $this->convertTo(RgbColorspace::class); - } - - public function toCmyk(): self - { - return $this->convertTo(CmykColorspace::class); - } - - public function toString(): string - { - return sprintf( - 'cmyk(%d, %d, %d, %d)', - $this->cyan()->value(), - $this->magenta()->value(), - $this->yellow()->value(), - $this->key()->value() - ); - } - - public function isGreyscale(): bool - { - return 0 === array_sum([ - $this->cyan()->value(), - $this->magenta()->value(), - $this->yellow()->value(), - ]); - } - - public function __toString(): string - { - return $this->toString(); - } -} diff --git a/src/Colors/Cmyk/Colorspace.php b/src/Colors/Cmyk/Colorspace.php deleted file mode 100644 index 76ce8ea3..00000000 --- a/src/Colors/Cmyk/Colorspace.php +++ /dev/null @@ -1,38 +0,0 @@ - $this->convertRgbColor($color), - default => $color, - }; - } - - protected function convertRgbColor(RgbColor $color): CmykColor - { - $c = (255 - $color->red()->value()) / 255.0 * 100; - $m = (255 - $color->green()->value()) / 255.0 * 100; - $y = (255 - $color->blue()->value()) / 255.0 * 100; - $k = intval(round(min([$c, $m, $y]))); - - $c = intval(round($c - $k)); - $m = intval(round($m - $k)); - $y = intval(round($y - $k)); - - return new CmykColor($c, $m, $y, $k); - } -} diff --git a/src/Colors/Cmyk/Decoders/StringColorDecoder.php b/src/Colors/Cmyk/Decoders/StringColorDecoder.php deleted file mode 100644 index 0f05ada9..00000000 --- a/src/Colors/Cmyk/Decoders/StringColorDecoder.php +++ /dev/null @@ -1,37 +0,0 @@ -[0-9\.]+%?), ?(?P[0-9\.]+%?), ?(?P[0-9\.]+%?), ?(?P[0-9\.]+%?)\)$/i'; - if (preg_match($pattern, $input, $matches) != 1) { - throw new DecoderException('Unable to decode input'); - } - - $values = array_map(function ($value) { - return intval(round(floatval(trim(str_replace('%', '', $value))))); - }, [$matches['c'], $matches['m'], $matches['y'], $matches['k']]); - - return new Color(...$values); - } -} diff --git a/src/Colors/Rgb/Color.php b/src/Colors/Rgb/Color.php index 89cf0b09..1a5723c5 100644 --- a/src/Colors/Rgb/Color.php +++ b/src/Colors/Rgb/Color.php @@ -2,8 +2,6 @@ namespace Intervention\Image\Colors\Rgb; -use Intervention\Image\Colors\Cmyk\Color as CmykColor; -use Intervention\Image\Colors\Cmyk\Colorspace as CmykColorspace; use Intervention\Image\Colors\Rgb\Channels\Blue; use Intervention\Image\Colors\Rgb\Channels\Green; use Intervention\Image\Colors\Rgb\Channels\Red; @@ -93,11 +91,6 @@ class Color implements ColorInterface return $colorspace->convertColor($this); } - public function toCmyk(): CmykColor - { - return $this->convertTo(CmykColorspace::class); - } - public function isFullyOpaque(): bool { return $this->alpha()->value() === 255; diff --git a/src/Colors/Rgb/Colorspace.php b/src/Colors/Rgb/Colorspace.php index 4c0bcb0f..4dbaae08 100644 --- a/src/Colors/Rgb/Colorspace.php +++ b/src/Colors/Rgb/Colorspace.php @@ -2,7 +2,6 @@ namespace Intervention\Image\Colors\Rgb; -use Intervention\Image\Colors\Cmyk\Color as CmykColor; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Interfaces\ColorspaceInterface; @@ -11,17 +10,7 @@ class Colorspace implements ColorspaceInterface public function convertColor(ColorInterface $color): ColorInterface { return match (get_class($color)) { - CmykColor::class => $this->convertCmykColor($color), default => $color, }; } - - protected function convertCmykColor(CmykColor $color): Color - { - return new Color( - (int) (255 * (1 - $color->cyan()->normalize()) * (1 - $color->key()->normalize())), - (int) (255 * (1 - $color->magenta()->normalize()) * (1 - $color->key()->normalize())), - (int) (255 * (1 - $color->yellow()->normalize()) * (1 - $color->key()->normalize())), - ); - } } diff --git a/src/Drivers/Gd/InputHandler.php b/src/Drivers/Gd/InputHandler.php index c545168f..5069e3fb 100644 --- a/src/Drivers/Gd/InputHandler.php +++ b/src/Drivers/Gd/InputHandler.php @@ -2,10 +2,9 @@ namespace Intervention\Image\Drivers\Gd; -use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder as RgbHexColorDecoder; -use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder as RgbStringColorDecoder; +use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder; +use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\HtmlColornameDecoder; -use Intervention\Image\Colors\Cmyk\Decoders\StringColorDecoder as CmykStringColorDecoder; use Intervention\Image\Drivers\Abstract\AbstractInputHandler; use Intervention\Image\Drivers\Gd\Decoders\ImageObjectDecoder; use Intervention\Image\Drivers\Gd\Decoders\ColorObjectDecoder; @@ -20,9 +19,8 @@ class InputHandler extends AbstractInputHandler protected $decoders = [ ImageObjectDecoder::class, ColorObjectDecoder::class, - RgbHexColorDecoder::class, - RgbStringColorDecoder::class, - CmykStringColorDecoder::class, + HexColorDecoder::class, + StringColorDecoder::class, // Decoders\TransparentColorDecoder::class, HtmlColornameDecoder::class, FilePointerImageDecoder::class, diff --git a/src/Drivers/Imagick/InputHandler.php b/src/Drivers/Imagick/InputHandler.php index f7c493b4..27ca7c5b 100644 --- a/src/Drivers/Imagick/InputHandler.php +++ b/src/Drivers/Imagick/InputHandler.php @@ -2,10 +2,9 @@ namespace Intervention\Image\Drivers\Imagick; -use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder as RgbHexColorDecoder; -use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder as RgbStringColorDecoder; +use Intervention\Image\Colors\Rgb\Decoders\HexColorDecoder; +use Intervention\Image\Colors\Rgb\Decoders\StringColorDecoder; use Intervention\Image\Colors\Rgb\Decoders\HtmlColornameDecoder; -use Intervention\Image\Colors\Cmyk\Decoders\StringColorDecoder as CmykStringColorDecoder; use Intervention\Image\Drivers\Abstract\AbstractInputHandler; use Intervention\Image\Drivers\Imagick\Decoders\ImageObjectDecoder; use Intervention\Image\Drivers\Imagick\Decoders\ColorObjectDecoder; @@ -20,9 +19,8 @@ class InputHandler extends AbstractInputHandler protected $decoders = [ ImageObjectDecoder::class, ColorObjectDecoder::class, - RgbHexColorDecoder::class, - RgbStringColorDecoder::class, - CmykStringColorDecoder::class, + HexColorDecoder::class, + StringColorDecoder::class, // Decoders\TransparentColorDecoder::class, HtmlColornameDecoder::class, FilePointerImageDecoder::class, diff --git a/src/Interfaces/ColorInterface.php b/src/Interfaces/ColorInterface.php index c1659ef2..6ba4cafe 100644 --- a/src/Interfaces/ColorInterface.php +++ b/src/Interfaces/ColorInterface.php @@ -2,13 +2,11 @@ namespace Intervention\Image\Interfaces; -use Intervention\Image\Colors\Cmyk\Color as CmykColor; -use Intervention\Image\Colors\Rgb\Color as RgbColor; +use Intervention\Image\Colors\Rgb\Color; interface ColorInterface { - public function toRgb(): RgbColor; - public function toCmyk(): CmykColor; + public function toRgb(): Color; public function toArray(): array; public function toString(): string; public function toHex(): string; diff --git a/tests/Colors/Cmyk/ChannelTest.php b/tests/Colors/Cmyk/ChannelTest.php deleted file mode 100644 index 44928abf..00000000 --- a/tests/Colors/Cmyk/ChannelTest.php +++ /dev/null @@ -1,48 +0,0 @@ -assertInstanceOf(Channel::class, $channel); - } - - public function testValue(): void - { - $channel = new Channel(10); - $this->assertEquals(10, $channel->value()); - } - - public function testNormalize(): void - { - $channel = new Channel(100); - $this->assertEquals(1, $channel->normalize()); - $channel = new Channel(0); - $this->assertEquals(0, $channel->normalize()); - $channel = new Channel(20); - $this->assertEquals(.2, $channel->normalize()); - } - - public function testValidate(): void - { - $this->expectException(ColorException::class); - new Channel(101); - - $this->expectException(ColorException::class); - new Channel(-1); - } -} diff --git a/tests/Colors/Cmyk/ColorTest.php b/tests/Colors/Cmyk/ColorTest.php deleted file mode 100644 index 070a199d..00000000 --- a/tests/Colors/Cmyk/ColorTest.php +++ /dev/null @@ -1,85 +0,0 @@ -assertInstanceOf(Color::class, $color); - } - - public function testChannels(): void - { - $color = new Color(10, 20, 30, 40); - $this->assertIsArray($color->channels()); - $this->assertCount(4, $color->channels()); - } - - public function testChannel(): void - { - $color = new Color(10, 20, 30, 40); - $channel = $color->channel(Cyan::class); - $this->assertInstanceOf(Cyan::class, $channel); - $this->assertEquals(10, $channel->value()); - } - - public function testCyanMagentaYellowKey(): void - { - $color = new Color(10, 20, 30, 40); - $this->assertInstanceOf(Cyan::class, $color->cyan()); - $this->assertInstanceOf(Magenta::class, $color->magenta()); - $this->assertInstanceOf(Yellow::class, $color->yellow()); - $this->assertInstanceOf(Key::class, $color->key()); - $this->assertEquals(10, $color->cyan()->value()); - $this->assertEquals(20, $color->magenta()->value()); - $this->assertEquals(30, $color->yellow()->value()); - $this->assertEquals(40, $color->key()->value()); - } - - public function testToArray(): void - { - $color = new Color(10, 20, 30, 40); - $this->assertEquals([10, 20, 30, 40], $color->toArray()); - } - - public function testNormalize(): void - { - $color = new Color(100, 50, 20, 0); - $this->assertEquals([1.0, 0.5, 0.2, 0.0], $color->normalize()); - } - - public function testToString(): void - { - $color = new Color(100, 50, 20, 0); - $this->assertEquals('cmyk(100, 50, 20, 0)', (string) $color); - } - - public function testToCmyk(): void - { - $color = new Color(0, 0, 0, 0); - $converted = $color->toCmyk(); - $this->assertInstanceOf(Color::class, $converted); - } - - public function testToRgb(): void - { - $color = new Color(0, 20, 20, 0); - $converted = $color->toRgb(); - $this->assertInstanceOf(RgbColor::class, $converted); - $this->assertEquals([255, 204, 204, 255], $converted->toArray()); - } -} diff --git a/tests/Colors/Cmyk/ColorspaceTest.php b/tests/Colors/Cmyk/ColorspaceTest.php deleted file mode 100644 index 818269fc..00000000 --- a/tests/Colors/Cmyk/ColorspaceTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertInstanceOf( - CmykColor::class, - $colorspace->convertColor( - new RgbColor(0, 0, 0) - ) - ); - } -} diff --git a/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php b/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php deleted file mode 100644 index f6af4237..00000000 --- a/tests/Colors/Cmyk/Decoders/StringColorDecoderTest.php +++ /dev/null @@ -1,35 +0,0 @@ -decode('cmyk(0,0,0,0)'); - $this->assertInstanceOf(Color::class, $result); - $this->assertEquals([0, 0, 0, 0], $result->toArray()); - - $result = $decoder->decode('cmyk(0, 100, 100, 0)'); - $this->assertInstanceOf(Color::class, $result); - $this->assertEquals([0, 100, 100, 0], $result->toArray()); - - $result = $decoder->decode('cmyk(0, 100, 100, 0)'); - $this->assertInstanceOf(Color::class, $result); - $this->assertEquals([0, 100, 100, 0], $result->toArray()); - - - $result = $decoder->decode('cmyk(0%, 100%, 100%, 0%)'); - $this->assertInstanceOf(Color::class, $result); - $this->assertEquals([0, 100, 100, 0], $result->toArray()); - } -} diff --git a/tests/Colors/Rgb/ColorTest.php b/tests/Colors/Rgb/ColorTest.php index f44191bd..131dcef7 100644 --- a/tests/Colors/Rgb/ColorTest.php +++ b/tests/Colors/Rgb/ColorTest.php @@ -2,7 +2,6 @@ namespace Intervention\Image\Tests\Colors\Rgb; -use Intervention\Image\Colors\Cmyk\Color as CmykColor; use Intervention\Image\Colors\Rgb\Channels\Red; use Intervention\Image\Colors\Rgb\Channels\Green; use Intervention\Image\Colors\Rgb\Channels\Blue; @@ -75,39 +74,6 @@ class ColorTest extends TestCase $this->assertEquals('rgb(181, 55, 23)', (string) $color); } - public function testToCmyk(): void - { - $color = new Color(0, 0, 0); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 0, 0, 100], $converted->toArray()); - - $color = new Color(255, 255, 255); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 0, 0, 0], $converted->toArray()); - - $color = new Color(255, 0, 0); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 100, 100, 0], $converted->toArray()); - - $color = new Color(255, 0, 255); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 100, 0, 0], $converted->toArray()); - - $color = new Color(255, 255, 0); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 0, 100, 0], $converted->toArray()); - - $color = new Color(255, 204, 204); - $converted = $color->toCmyk(); - $this->assertInstanceOf(CmykColor::class, $converted); - $this->assertEquals([0, 20, 20, 0], $converted->toArray()); - } - public function testToRgb(): void { $color = new Color(181, 55, 23); diff --git a/tests/Colors/Rgb/ColorspaceTest.php b/tests/Colors/Rgb/ColorspaceTest.php deleted file mode 100644 index be7808c5..00000000 --- a/tests/Colors/Rgb/ColorspaceTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertInstanceOf( - RgbColor::class, - $colorspace->convertColor( - new CmykColor(0, 0, 0, 0) - ) - ); - } -} diff --git a/tests/Drivers/Gd/InputHandlerTest.php b/tests/Drivers/Gd/InputHandlerTest.php index 07328d49..7be7f4e0 100644 --- a/tests/Drivers/Gd/InputHandlerTest.php +++ b/tests/Drivers/Gd/InputHandlerTest.php @@ -2,7 +2,7 @@ namespace Intervention\Image\Tests\Drivers\Gd; -use Intervention\Image\Colors\Rgb\Color as RgbColor; +use Intervention\Image\Colors\Rgb\Color; use Intervention\Image\Drivers\Gd\Image; use Intervention\Image\Drivers\Gd\InputHandler; use Intervention\Image\Exceptions\DecoderException; @@ -58,37 +58,37 @@ class GdInputHandlerTest extends TestCase $handler = new InputHandler(); $input = 'ccff33'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([204, 255, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = 'cf3'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([204, 255, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = '#123456'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([18, 52, 86, 255], $result->toArray()); $handler = new InputHandler(); $input = '#333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = '#3333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 51], $result->toArray()); $handler = new InputHandler(); $input = '#33333333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 51], $result->toArray()); } @@ -96,12 +96,12 @@ class GdInputHandlerTest extends TestCase { $handler = new InputHandler(); $result = $handler->handle('rgb(10, 20, 30)'); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([10, 20, 30, 255], $result->toArray()); $handler = new InputHandler(); $result = $handler->handle('rgba(10, 20, 30, 1.0)'); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([10, 20, 30, 255], $result->toArray()); } diff --git a/tests/Drivers/Imagick/InputHandlerTest.php b/tests/Drivers/Imagick/InputHandlerTest.php index 158edd5e..df2a5b1a 100644 --- a/tests/Drivers/Imagick/InputHandlerTest.php +++ b/tests/Drivers/Imagick/InputHandlerTest.php @@ -2,7 +2,7 @@ namespace Intervention\Image\Tests\Drivers\Imagick; -use Intervention\Image\Colors\Rgb\Color as RgbColor; +use Intervention\Image\Colors\Rgb\Color; use Intervention\Image\Drivers\Imagick\Image; use Intervention\Image\Drivers\Imagick\InputHandler; use Intervention\Image\Exceptions\DecoderException; @@ -58,37 +58,37 @@ class InputHandlerTest extends TestCase $handler = new InputHandler(); $input = 'ccff33'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([204, 255, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = 'cf3'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([204, 255, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = '#123456'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([18, 52, 86, 255], $result->toArray()); $handler = new InputHandler(); $input = '#333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 255], $result->toArray()); $handler = new InputHandler(); $input = '#3333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 51], $result->toArray()); $handler = new InputHandler(); $input = '#33333333'; $result = $handler->handle($input); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([51, 51, 51, 51], $result->toArray()); } @@ -96,12 +96,12 @@ class InputHandlerTest extends TestCase { $handler = new InputHandler(); $result = $handler->handle('rgb(10, 20, 30)'); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([10, 20, 30, 255], $result->toArray()); $handler = new InputHandler(); $result = $handler->handle('rgba(10, 20, 30, 1.0)'); - $this->assertInstanceOf(RgbColor::class, $result); + $this->assertInstanceOf(Color::class, $result); $this->assertEquals([10, 20, 30, 255], $result->toArray()); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 81eddb55..cfd60927 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,7 +2,7 @@ namespace Intervention\Image\Tests; -use Intervention\Image\Colors\Rgb\Color as RgbColor; +use Intervention\Image\Colors\Rgb\Color; use Intervention\Image\Interfaces\ColorInterface; use Mockery\Adapter\Phpunit\MockeryTestCase; @@ -25,7 +25,7 @@ abstract class TestCase extends MockeryTestCase protected function assertTransparency(ColorInterface $color) { - $this->assertInstanceOf(RgbColor::class, $color); + $this->assertInstanceOf(Color::class, $color); $this->assertEquals(0, $color->toRgb()->alpha()->value()); } }