Passed
Push — release/0.4.13 ( 7c5517...023c31 )
by Mathieu
02:18
created

Container::setWarehouse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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