Passed
Push — master ( bdc105...ec8122 )
by Peter
01:57
created

CollectionDto   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 50%

Importance

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

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 3
    protected function __construct(string $class, array $items)
19
    {
20 3
        Assert::allIsInstanceOf($items, $class);
21
22 3
        $this->items = $items;
23 3
    }
24
25
    public function getIterator(): Traversable
26
    {
27
        return new ArrayIterator($this->items);
28
    }
29
30
    public function count(): int
31
    {
32
        return count($this->items);
33
    }
34
}
35