Total Complexity | 8 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | final class Changes implements IteratorAggregate, Countable |
||
13 | { |
||
14 | /** @var Change[] */ |
||
15 | private $changes; |
||
16 | |||
17 | private function __construct() |
||
18 | { |
||
19 | } |
||
20 | |||
21 | public static function empty() : self |
||
22 | { |
||
23 | static $empty; |
||
24 | |||
25 | if ($empty) { |
||
26 | return $empty; |
||
27 | } |
||
28 | |||
29 | $empty = new self(); |
||
30 | |||
31 | $empty->changes = []; |
||
32 | |||
33 | return $empty; |
||
34 | } |
||
35 | |||
36 | public static function fromList(Change ...$changes) : self |
||
43 | } |
||
44 | |||
45 | public function mergeWith(self $other) : self |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * {@inheritDoc} |
||
56 | * |
||
57 | * @return ArrayIterator|Change[] |
||
58 | */ |
||
59 | public function getIterator() : ArrayIterator |
||
60 | { |
||
61 | return new ArrayIterator($this->changes); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritDoc} |
||
66 | */ |
||
67 | public function count() : int |
||
70 | } |
||
71 | } |
||
72 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.