Conditions | 2 |
Paths | 2 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
34 | 376 | public static function validate(string $granularity): string |
|
35 | { |
||
36 | 376 | $granularity = strtolower($granularity); |
|
37 | 376 | if (!Granularity::isValidValue($granularity)) { |
|
38 | 5 | throw new InvalidArgumentException( |
|
39 | 5 | 'The given granularity is invalid: ' . $granularity . '. ' . |
|
40 | 5 | 'Allowed are: ' . implode(',', Granularity::values()) |
|
41 | ); |
||
42 | } |
||
43 | |||
44 | 372 | return $granularity; |
|
45 | } |
||
46 | } |