Total Complexity | 6 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
11 | final class TypeMap extends ArrayObject |
||
12 | { |
||
13 | /** |
||
14 | * @param string $offset |
||
15 | * @return TypeArgument |
||
16 | */ |
||
17 | public function offsetGet($offset): TypeArgument |
||
18 | { |
||
19 | if (!is_string($offset)) { |
||
|
|||
20 | $this->throw($offset, 'string', __METHOD__, 0); |
||
21 | } |
||
22 | return parent::offsetGet($offset); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param string $offset |
||
27 | * @param TypeArgument $value |
||
28 | */ |
||
29 | public function offsetSet($offset, $value): void |
||
30 | { |
||
31 | if (!is_string($offset)) { |
||
32 | $this->throw($offset, 'string', __METHOD__, 0); |
||
33 | } |
||
34 | if (!$value instanceof TypeArgument) { |
||
35 | $this->throw($value, TypeArgument::class, __METHOD__, 1); |
||
36 | } |
||
37 | parent::offsetSet($offset, $value); |
||
38 | } |
||
39 | |||
40 | private function throw($value, string $type, string $source, int $argument): void |
||
48 | )); |
||
49 | } |
||
50 | } |
||
51 |