Passed
Push — master ( 1107f1...a96017 )
by Peter
34s
created

CollectionDto::offsetUnset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PtrTn\Battlerite\Dto;
4
5
use ArrayAccess;
6
use Countable;
7
use IteratorAggregate;
8
use Webmozart\Assert\Assert;
9
10
abstract class CollectionDto implements IteratorAggregate, Countable, ArrayAccess
11
{
12
    /**
13
     * @var array
14
     */
15
    public $items;
16
17 22
    protected function __construct(string $class, array $items)
18
    {
19 22
        Assert::allIsInstanceOf($items, $class);
20
21 22
        $this->items = $items;
22 22
    }
23
24 6
    public function count(): int
25
    {
26 6
        return count($this->items);
27
    }
28
29 1
    public function offsetExists($offset)
30
    {
31 1
        return array_key_exists($offset, $this->items);
32
    }
33
34 3
    public function offsetGet($offset)
35
    {
36 3
        return $this->items[$offset];
37
    }
38
39 1
    public function offsetSet($offset, $value)
40
    {
41 1
        $this->items[$offset] = $value;
42 1
    }
43
44 1
    public function offsetUnset($offset)
45
    {
46 1
        unset($this->items[$offset]);
47 1
    }
48
}
49