Total Complexity | 4 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | final class GenericType implements Type |
||
11 | { |
||
12 | use Nullable; |
||
13 | |||
14 | /** @var string */ |
||
15 | private $type; |
||
16 | |||
17 | public function __construct(string $type) |
||
20 | } |
||
21 | |||
22 | public function validate($value) |
||
23 | { |
||
24 | if ( |
||
25 | ! $value instanceof $this->type |
||
26 | ) { |
||
27 | throw WrongType::withMessage("must be of type {$this->type}"); |
||
28 | } |
||
29 | |||
30 | return $value; |
||
31 | } |
||
32 | |||
33 | public function __toString(): string |
||
36 | } |
||
37 | } |
||
38 |