Passed
Pull Request — master (#25)
by Mathieu
02:35
created

Container::setWarehouse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Suricate;
6
7
use ArrayAccess;
8
9
class Container implements ArrayAccess
10
{
11
    protected $content;
12
13
    public function __construct(array $values = [])
14 13
    {
15
        $this->content = $values;
16 13
    }
17 13
18
    /**
19
     * ArrayAccess offsetExists implementation
20
     *
21
     * @param mixed $offset offset to check
22
     * @return bool
23
     */
24
    public function offsetExists($offset): bool
25 3
    {
26
        return isset($this->content[$offset]);
27 3
    }
28
29
    /**
30
     * ArrayAccess offsetGet implementation
31
     *
32
     * @param mixed $offset offset to get
33
     * @return mixed
34
     */
35
    public function offsetGet($offset)
36
    {
37 22
        if (isset($this->content[$offset])) {
38
            return $this->content[$offset];
39 22
        }
40 20
41
        return null;
42
    }
43
44 12
    /**
45 11
     * ArrayAccess offsetSet implementation
46 11
     *
47
     * @param mixed $offset offset to set
48
     * @param mixed $value  value to set
49 1
     * @return void
50
     */
51
    public function offsetSet($offset, $value)
52
    {
53
        $this->content[$offset] = $value;
54
    }
55
56
    /**
57
     * \ArrayAccess offsetUnset implementation
58
     *
59 1
     * @param mixed $offset offset to unset
60
     * @return void
61 1
     */
62
    public function offsetUnset($offset)
63
    {
64
        if (isset($this->content[$offset])) {
65
            unset($this->content[$offset]);
66
        }
67
    }
68
}
69