| Total Complexity | 12 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class ArrayType implements Type |
||
| 14 | { |
||
| 15 | /** @var Type */ |
||
| 16 | private $keyType; |
||
| 17 | |||
| 18 | /** @var Type */ |
||
| 19 | private $valueType; |
||
| 20 | |||
| 21 | 292 | public function __construct(Type $keyType, Type $valueType) |
|
| 25 | 292 | } |
|
| 26 | |||
| 27 | 1 | public function getKeyType() : Type |
|
| 28 | { |
||
| 29 | 1 | return $this->keyType; |
|
| 30 | } |
||
| 31 | |||
| 32 | 205 | public function getValueType() : Type |
|
| 33 | { |
||
| 34 | 205 | return $this->valueType; |
|
| 35 | } |
||
| 36 | |||
| 37 | 7 | public function describe() : string |
|
| 38 | { |
||
| 39 | 7 | if ($this->keyType instanceof MixedType |
|
| 40 | 5 | || $this->keyType->describe() === 'int|string' |
|
| 41 | 7 | || $this->keyType->describe() === 'string|int' |
|
| 42 | ) { |
||
| 43 | 4 | return sprintf('array<%s>', $this->valueType->describe()); |
|
| 44 | } |
||
| 45 | |||
| 46 | 3 | return sprintf('array<%s, %s>', $this->keyType->describe(), $this->valueType->describe()); |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param mixed $value |
||
| 51 | */ |
||
| 52 | 218 | public function validate($value) : bool |
|
| 69 | } |
||
| 70 | } |
||
| 71 |