Completed
Push — master ( 7aeae4...94fdcc )
by Peter
02:27 queued 33s
created

CollectionDto::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto;
4
5
use ArrayIterator;
6
use Countable;
7
use IteratorAggregate;
8
use Traversable;
9
use Webmozart\Assert\Assert;
10
11
abstract class CollectionDto implements IteratorAggregate, Countable
12
{
13
    /**
14
     * @var array
15
     */
16
    public $items;
17
18 8
    protected function __construct(string $class, array $items)
19
    {
20 8
        Assert::allIsInstanceOf($items, $class);
21
22 8
        $this->items = $items;
23 8
    }
24
25 1
    public function getIterator(): Traversable
26
    {
27 1
        return new ArrayIterator($this->items);
28
    }
29
30 2
    public function count(): int
31
    {
32 2
        return count($this->items);
33
    }
34
}
35