ArrayAccessible   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 46
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetUnset() 0 3 1
A offsetSet() 0 3 1
A offsetGet() 0 3 1
A offsetExists() 0 3 1
1
<?php
2
3
namespace TPG\Pcflib\Traits;
4
5
trait ArrayAccessible
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $items = [];
11
12
    /**
13
     * Check if an offset exists
14
     * @param mixed $offset
15
     * @return bool
16
     */
17
    public function offsetExists($offset): bool
18
    {
19
        return array_key_exists($offset, $this->items);
20
    }
21
22
    /**
23
     * Offset to retrieve
24
     * @param mixed $offset
25
     * @return mixed
26
     */
27
    public function offsetGet($offset)
28
    {
29
        return $this->items[$offset];
30
    }
31
32
    /**
33
     * Offset to set
34
     * @param mixed $offset
35
     * @param mixed $value
36
     * @return void
37
     */
38
    public function offsetSet($offset, $value)
39
    {
40
        $this->items[$offset] = $value;
41
    }
42
43
    /**
44
     * Offset to unset
45
     * @param mixed $offset
46
     * @return void
47
     */
48
    public function offsetUnset($offset)
49
    {
50
        unset($this->items[$offset]);
51
    }
52
}