Total Complexity | 3 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class RGBToHEXConverter implements ConverterInterface |
||
13 | { |
||
14 | 131 | public function convert(Color $color): Color |
|
15 | { |
||
16 | /* @var RGB $color */ |
||
17 | 131 | Assert::isInstanceOf($color, RGB::class, sprintf('color should be an instance of [%s]', RGB::class)); |
|
18 | |||
19 | 130 | $red = dechex($color->getRed()); |
|
20 | 130 | $green = dechex($color->getGreen()); |
|
21 | 130 | $blue = dechex($color->getBlue()); |
|
22 | |||
23 | 130 | $red = str_pad($red, 2, '0', STR_PAD_LEFT); |
|
24 | 130 | $green = str_pad($green, 2, '0', STR_PAD_LEFT); |
|
25 | 130 | $blue = str_pad($blue, 2, '0', STR_PAD_LEFT); |
|
26 | |||
27 | 130 | return new HEX($red, $green, $blue); |
|
28 | } |
||
29 | |||
30 | 924 | public static function supportsFrom(): string |
|
33 | } |
||
34 | |||
35 | 924 | public static function supportsTo(): string |
|
40 |