Total Complexity | 9 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
6 | abstract class AbstractTypedArray extends \ArrayObject |
||
7 | { |
||
8 | protected $valueType; |
||
9 | |||
10 | 18 | public function __construct(string $valueType, array $array = [], int $flags = 0, string $iteratorClass = "ArrayIterator") { |
|
11 | 18 | $this->valueType = $valueType; |
|
12 | |||
13 | 18 | $this->checkAllElements($array); |
|
14 | |||
15 | 18 | parent::__construct($array, $flags, $iteratorClass); |
|
16 | 18 | } |
|
17 | |||
18 | 13 | public function offsetSet($offset, $value) |
|
19 | { |
||
20 | 13 | $this->checkType($value); |
|
21 | |||
22 | 11 | $this->checkOffset($offset); |
|
23 | |||
24 | 9 | parent::offsetSet($offset, $value); |
|
25 | 9 | } |
|
26 | |||
27 | 1 | public function exchangeArray($array) |
|
32 | 1 | } |
|
33 | |||
34 | 18 | protected function checkType($value): void |
|
38 | } |
||
39 | 16 | } |
|
40 | |||
41 | abstract protected function checkOffset($offset): void; |
||
42 | |||
43 | 18 | private function checkAllElements(array $array): void |
|
48 | 18 | }); |
|
49 | } |
||
50 | } |