Total Complexity | 9 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class Validator |
||
6 | { |
||
7 | /** |
||
8 | * @param $color |
||
9 | * |
||
10 | * @return bool |
||
11 | */ |
||
12 | 39 | public static function isValidHex(string $color) : bool |
|
13 | { |
||
14 | 39 | $color = ltrim($color, '#'); |
|
15 | |||
16 | 39 | return ctype_xdigit($color) && (strlen($color) === 6 || strlen($color) === 3); |
|
17 | } |
||
18 | |||
19 | /** |
||
20 | * |
||
21 | * @param $red |
||
22 | * @param $green |
||
23 | * @param $blue |
||
24 | * |
||
25 | * @return bool|mixed |
||
26 | */ |
||
27 | public static function isValidRgb(int $red, int $green, int $blue) : bool |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * |
||
37 | * @param float $hue |
||
38 | * @param float $saturation |
||
39 | * @param float $lightness |
||
40 | * |
||
41 | * @return bool |
||
42 | */ |
||
43 | public static function isValidHsl(float $hue, float $saturation, float $lightness) : bool |
||
44 | { |
||
45 | // Check to see the values are between 0 and 1 and return false if any are outside the bounds |
||
46 | 3 | return array_reduce([$hue, $saturation, $lightness], function ($carry, $color) { |
|
47 | 3 | return $color >= 0 && $color <= 1 && $carry === true; |
|
48 | 3 | }, true); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * |
||
53 | * @param float $degrees |
||
54 | * |
||
55 | * @return bool|mixed |
||
56 | */ |
||
57 | 5 | public static function isValidAdjustment(float $degrees) : bool |
|
61 | } |
||
62 | } |
||
63 |