Total Complexity | 11 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 77.27% |
Changes | 0 |
1 | <?php |
||
11 | final class MapType implements CompositeType |
||
12 | { |
||
13 | /** @var ScalarType|UnionType */ |
||
14 | private $keyType; |
||
15 | |||
16 | /** @var Type */ |
||
17 | private $valueType; |
||
18 | |||
19 | 8 | public function __construct(Type $keyType, Type $valueType) |
|
20 | { |
||
21 | 8 | assert($keyType instanceof ScalarType || $keyType instanceof UnionType, 'Invalid key type'); |
|
22 | |||
23 | 8 | $this->keyType = $keyType; |
|
24 | 8 | $this->valueType = $valueType; |
|
25 | 8 | } |
|
26 | |||
27 | public function getKeyType() : ScalarType |
||
28 | { |
||
29 | return $this->keyType; |
||
|
|||
30 | } |
||
31 | |||
32 | public function getValueType() : Type |
||
35 | } |
||
36 | |||
37 | 4 | public function describe() : string |
|
38 | { |
||
39 | 4 | return sprintf('array<%s, %s>', $this->keyType->describe(), $this->valueType->describe()); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param mixed $value |
||
44 | */ |
||
45 | 3 | public function validate($value) : bool |
|
62 | } |
||
63 | |||
64 | 1 | public function acceptsNull() : bool |
|
67 | } |
||
68 | } |
||
69 |