DefinitionsCollection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Nip\Dispatcher\Resolver\Cache;
4
5
/**
6
 * Class DefinitionsCollection
7
 * @package Nip\Dispatcher\Resolver\Cache
8
 */
9
class DefinitionsCollection
10
{
11
    protected $items = [];
12
13
    /**
14
     * DefinitionsCollection constructor.
15
     * @param array $items
16
     */
17 4
    public function __construct(array $items)
18
    {
19 4
        $this->items = $items;
20 4
    }
21
22
    /**
23
     * @return array
24
     */
25 5
    public function all()
26
    {
27 5
        return $this->items;
28
    }
29
30
    /**
31
     * @param $items
32
     * @return array
33
     */
34 3
    public function replace($items)
35
    {
36 3
        return $this->items = $items + $this->items;
37
    }
38
39
    /**
40
     * @param $offset
41
     * @return bool
42
     */
43 3
    public function has($offset)
44
    {
45 3
        return $this->offsetExists($offset);
46
    }
47
48
    /**
49
     * @param $offset
50
     * @return mixed
51
     */
52 3
    public function get($offset)
53
    {
54 3
        return $this->offsetGet($offset);
55
    }
56
57
    /**
58
     * @param $offset
59
     * @param $value
60
     * @return mixed
61
     */
62 3
    public function set($offset, $value)
63
    {
64 3
        $this->offsetSet($offset, $value);
65 3
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70 3
    public function offsetExists($offset)
71
    {
72 3
        return isset($this->items[$offset]);
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 3
    public function offsetGet($offset)
79
    {
80 3
        return $this->items[$offset];
81
    }
82
83
    /**
84
     * @inheritdoc
85
     * @param string $value
86
     */
87 3
    public function offsetSet($offset, $value)
88
    {
89 3
        if ($offset == null) {
90
            $this->items[] = $value;
91
        } else {
92 3
            $this->items[$offset] = $value;
93
        }
94 3
    }
95
}
96