| Total Complexity | 10 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class RGB extends Color |
||
| 10 | { |
||
| 11 | private $red; |
||
| 12 | private $green; |
||
| 13 | private $blue; |
||
| 14 | |||
| 15 | 735 | public function __construct(int $red, int $green, int $blue) |
|
| 16 | { |
||
| 17 | 735 | if ($red < 0 || $red > 255) { |
|
| 18 | 2 | throw new InvalidArgumentException(sprintf('Given red value %d is expected to be between %d and %d >> [%2$d,%3$d]', $red, 0, 255)); |
|
| 19 | } |
||
| 20 | |||
| 21 | 733 | if ($green < 0 || $green > 255) { |
|
| 22 | 2 | throw new InvalidArgumentException(sprintf('Given green value %d is expected to be between %d and %d >> [%2$d,%3$d]', $green, 0, 255)); |
|
| 23 | } |
||
| 24 | |||
| 25 | 731 | if ($blue < 0 || $blue > 255) { |
|
| 26 | 2 | throw new InvalidArgumentException(sprintf('Given blue value %d is expected to be between %d and %d >> [%2$d,%3$d]', $blue, 0, 255)); |
|
| 27 | } |
||
| 28 | |||
| 29 | 729 | $this->red = $red; |
|
| 30 | 729 | $this->green = $green; |
|
| 31 | 729 | $this->blue = $blue; |
|
| 32 | 729 | } |
|
| 33 | |||
| 34 | 727 | public function getRed(): int |
|
| 37 | } |
||
| 38 | |||
| 39 | 727 | public function getGreen(): int |
|
| 42 | } |
||
| 43 | |||
| 44 | 727 | public function getBlue(): int |
|
| 47 | } |
||
| 48 | } |
||
| 49 |