Conditions | 8 |
Paths | 5 |
Total Lines | 16 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 8.048 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 10 | protected function afterElementAdd($element): void |
|
21 | { |
||
22 | 10 | $firstElement = $this->elements[0]; |
|
23 | 10 | if (null === $firstElement && !count($this->elements)) { |
|
24 | return; |
||
25 | } |
||
26 | 10 | if (is_object($firstElement)) { |
|
27 | 2 | if (!is_object($element) || (get_class($firstElement) !== get_class($element))) { |
|
28 | 2 | throw new InvalidArgumentException('Collection must contain elements with identical types'); |
|
29 | } |
||
30 | 2 | return; |
|
31 | } |
||
32 | 8 | if (is_object($element) || (gettype($firstElement) !== gettype($element))) { |
|
33 | 7 | throw new InvalidArgumentException('Collection must contain elements with identical types'); |
|
34 | } |
||
35 | 8 | parent::afterElementAdd($element); |
|
36 | 8 | } |
|
38 |