Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
12 | class Colors |
||
13 | { |
||
14 | const HSV_VALUE = 1.0; |
||
15 | |||
16 | /** |
||
17 | * @param Config $config |
||
18 | * |
||
19 | * @return Color\RgbColor[] |
||
20 | * |
||
21 | * @throws \Barryvanveen\CCA\Exceptions\InvalidColorsException |
||
22 | */ |
||
23 | 9 | public static function getColors(Config $config): array |
|
24 | { |
||
25 | 9 | if ($config->imageColors() === null) { |
|
26 | 3 | return self::getEvenlyDistributedColors($config->imageHue(), $config->states()); |
|
27 | } |
||
28 | |||
29 | 6 | $colors = $config->imageColors(); |
|
30 | |||
31 | 6 | if (count($colors) !== $config->states()) { |
|
32 | 3 | throw new InvalidColorsException("Not enough colors specified."); |
|
33 | } |
||
34 | |||
35 | 3 | return $colors; |
|
36 | } |
||
37 | |||
38 | 3 | protected static function getEvenlyDistributedColors(int $hue, int $numberOfColors): array |
|
54 | } |
||
55 | } |
||
56 |