Completed
Push — master ( 56570e...2c8793 )
by Gabriel
07:17
created

DefinitionsCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 1
crap 1
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 View Code Duplication
        if ($offset == null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
            $this->items[] = $value;
91
        } else {
92 3
            $this->items[$offset] = $value;
93
        }
94 3
    }
95
}
96