| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class Changes implements IteratorAggregate |
||
| 11 | { |
||
| 12 | /** @var Change[] */ |
||
| 13 | private $changes = []; |
||
| 14 | |||
| 15 | private function __construct() |
||
| 17 | } |
||
| 18 | |||
| 19 | public static function new(): self |
||
| 22 | } |
||
| 23 | |||
| 24 | public static function fromArray(array $changes): self |
||
| 25 | { |
||
| 26 | Assert::that($changes)->all()->isInstanceOf(Change::class); |
||
| 27 | $instance = self::new(); |
||
| 28 | $instance->changes = $changes; |
||
| 29 | return $instance; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function withAddedChange(Change $change): self |
||
| 33 | { |
||
| 34 | $new = clone $this; |
||
| 35 | $new->changes[] = $change; |
||
| 36 | return $new; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritDoc} |
||
| 41 | */ |
||
| 42 | public function getIterator() : ArrayIterator |
||
| 45 | } |
||
| 46 | } |
||
| 47 |