| Total Complexity | 12 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 82.61% |
| 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 | 290 | public function __construct(Type $keyType, Type $valueType) |
|
| 25 | 290 | } |
|
| 26 | |||
| 27 | public function getKeyType() : Type |
||
| 28 | { |
||
| 29 | return $this->keyType; |
||
| 30 | } |
||
| 31 | |||
| 32 | 36 | public function getValueType() : Type |
|
| 33 | { |
||
| 34 | 36 | return $this->valueType; |
|
| 35 | } |
||
| 36 | |||
| 37 | 7 | public function describe() : string |
|
| 38 | { |
||
| 39 | if ( |
||
| 40 | 7 | $this->keyType instanceof MixedType |
|
| 41 | 5 | || $this->keyType->describe() === 'int|string' |
|
| 42 | 7 | || $this->keyType->describe() === 'string|int' |
|
| 43 | ) { |
||
| 44 | 4 | return sprintf('array<%s>', $this->valueType->describe()); |
|
| 45 | } |
||
| 46 | |||
| 47 | 3 | return sprintf('array<%s, %s>', $this->keyType->describe(), $this->valueType->describe()); |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param mixed $value |
||
| 52 | */ |
||
| 53 | 214 | public function validate($value) : bool |
|
| 70 | } |
||
| 71 | } |
||
| 72 |