| Total Complexity | 6 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class Primitive implements Type |
||
| 14 | { |
||
| 15 | private $function; |
||
| 16 | |||
| 17 | 56 | public function __construct(string $primitive) |
|
| 18 | { |
||
| 19 | 56 | if (!function_exists('is_'.$primitive)) { |
|
| 20 | 10 | throw new NotAPrimitiveType($primitive); |
|
| 21 | } |
||
| 22 | |||
| 23 | 53 | $this->function = 'is_'.$primitive; |
|
| 24 | 53 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | 33 | public function accepts($value): bool |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | 11 | public static function fromString(Str $value): Type |
|
| 38 | { |
||
| 39 | try { |
||
| 40 | 11 | return new self((string) $value); |
|
| 41 | 9 | } catch (NotAPrimitiveType $e) { |
|
| 42 | 9 | throw new ValueNotSupported((string) $value, 0, $e); |
|
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | 3 | public function __toString(): string |
|
| 52 | } |
||
| 53 | } |
||
| 54 |