Total Complexity | 2 |
Total Lines | 22 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class NullHandling extends Enum |
||
|
|||
14 | { |
||
15 | public const NULL_STRING = 'nullString'; |
||
16 | public const EMPTY_STRING = 'emptyString'; |
||
17 | public const RETURN_NULL = 'returnNull'; |
||
18 | |||
19 | /** |
||
20 | * @param string $nullHandling |
||
21 | * |
||
22 | * @return string |
||
23 | * @throws InvalidArgumentException |
||
24 | */ |
||
25 | 5 | public static function validate(string $nullHandling): string |
|
26 | { |
||
27 | 5 | if (!NullHandling::isValidValue($nullHandling)) { |
|
28 | 1 | throw new InvalidArgumentException( |
|
29 | 1 | 'The given NullHandling value is invalid: ' . $nullHandling . '. ' . |
|
30 | 1 | 'Allowed are: ' . implode(',', NullHandling::values()) |
|
31 | ); |
||
32 | } |
||
33 | |||
34 | 4 | return $nullHandling; |
|
35 | } |
||
36 | } |