Total Complexity | 7 |
Total Lines | 54 |
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 new(): self |
||
22 | { |
||
23 | return new self(); |
||
24 | } |
||
25 | |||
26 | public static function fromArray(array $changes): self |
||
27 | { |
||
28 | Assert::that($changes)->all()->isInstanceOf(Change::class); |
||
29 | $instance = self::new(); |
||
30 | $instance->changes = $changes; |
||
31 | return $instance; |
||
32 | } |
||
33 | |||
34 | public function mergeWith(self $other) : self |
||
41 | } |
||
42 | |||
43 | public function withAddedChange(Change $change): self |
||
44 | { |
||
45 | $new = clone $this; |
||
46 | $new->changes[] = $change; |
||
47 | return $new; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritDoc} |
||
52 | * |
||
53 | * @return Change[] |
||
54 | */ |
||
55 | public function getIterator() : ArrayIterator |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * {@inheritDoc} |
||
62 | */ |
||
63 | public function count() : int |
||
68 |