| Total Complexity | 10 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class Type |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Build the appropriate specification for the given type |
||
| 17 | * |
||
| 18 | * @param string $type |
||
| 19 | * |
||
| 20 | * @return SpecificationInterface |
||
| 21 | */ |
||
| 22 | 446 | public static function of(string $type): SpecificationInterface |
|
| 23 | { |
||
| 24 | 446 | if (\function_exists('is_'.$type)) { |
|
| 25 | 410 | return new PrimitiveType($type); |
|
| 26 | } |
||
| 27 | |||
| 28 | 200 | if ($type === 'variable') { |
|
| 29 | 4 | return new VariableType; |
|
| 30 | } |
||
| 31 | |||
| 32 | 198 | if ($type === 'mixed') { |
|
| 33 | 2 | return new MixedType; |
|
| 34 | } |
||
| 35 | |||
| 36 | 198 | return new ClassType($type); |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Return the type of the given value |
||
| 41 | * |
||
| 42 | * @param mixed $value |
||
| 43 | * |
||
| 44 | * @return string |
||
| 45 | */ |
||
| 46 | 16 | public static function determine($value): string |
|
| 68 | } |
||
| 69 | } |
||
| 71 |