| Total Complexity | 2 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class DataType extends Enum |
||
|
|
|||
| 14 | { |
||
| 15 | public const STRING = 'string'; |
||
| 16 | public const FLOAT = 'float'; |
||
| 17 | public const LONG = 'long'; |
||
| 18 | public const DOUBLE = 'double'; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Validate the DataType. |
||
| 22 | * |
||
| 23 | * @param string $outputType |
||
| 24 | * |
||
| 25 | * @return string |
||
| 26 | * @throws InvalidArgumentException |
||
| 27 | */ |
||
| 28 | 97 | public static function validate(string $outputType): string |
|
| 29 | { |
||
| 30 | 97 | $outputType = strtolower($outputType); |
|
| 31 | 97 | if (!self::isValidValue($outputType)) { |
|
| 32 | 3 | throw new InvalidArgumentException( |
|
| 33 | 3 | 'The given output type is invalid: ' . $outputType . '. ' . |
|
| 34 | 3 | 'Allowed are: ' . implode(',', DataType::values()) |
|
| 35 | ); |
||
| 36 | } |
||
| 37 | |||
| 38 | 94 | return $outputType; |
|
| 39 | } |
||
| 40 | } |