Completed
Push — master ( ec8122...285919 )
by Peter
01:48
created

CollectionDto   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10

3 Methods

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