Collection::getIterator()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
declare(strict_types = 1);
13
14
namespace Aggrego\FragmentedDataBoard\Board\Prototype\Shard;
15
16
use ArrayIterator;
17
use Assert\Assertion;
18
use Iterator;
19
use IteratorAggregate;
20
21
class Collection implements IteratorAggregate
22
{
23
    /** @var array */
24
    private $list;
25
26
    public function __construct(array $list = [])
27
    {
28
        Assertion::allIsInstanceOf($list, Item::class);
29
        $this->list = $list;
30
    }
31
32
    public function add(Item $item): void
33
    {
34
        $this->list[] = $item;
35
    }
36
37
    public function getIterator(): Iterator
38
    {
39
        return new ArrayIterator($this->list);
40
    }
41
}
42