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

Collection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 3 1
A add() 0 3 1
A __construct() 0 4 1
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