Passed
Push — master ( 2ee0d1...1e8995 )
by Tomasz
03:21
created

Collection::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Aggrego\Domain\Api\Application\Profile\BoardConstruction\InitialBoardModel\Shard;
6
7
use ArrayIterator;
8
use Assert\Assertion;
9
use Iterator;
10
use IteratorAggregate;
11
12
class Collection implements IteratorAggregate
13
{
14
    /** @var array */
15
    private $list;
16
17
    public function __construct(array $list = [])
18
    {
19
        Assertion::allIsInstanceOf($list, Item::class);
20
        $this->list = $list;
21
    }
22
23
    public function add(Item $item): void
24
    {
25
        $this->list[] = $item;
26
    }
27
28
    public function getIterator(): Iterator
29
    {
30
        return new ArrayIterator($this->list);
31
    }
32
}
33