Completed
Push — master ( 8aeefb...cee8b2 )
by Charis
02:18
created

ArrayAccessAble::getIterator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 0
1
<?php
2
3
namespace Resilient\Traits;
4
5
trait ArrayAccessAble
6
{
7
    protected $offset = [];
8
9
    /**
10
     * ArrayAccess Implementations
11
     */
12
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function offsetExists($key)
17
    {
18
        return array_key_exists($key, $this->offset);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function offsetGet($key)
25
    {
26
        return $this->offset[$key];
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function offsetSet($key, $value)
33
    {
34
        $this->offset[$key] = $value;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function offsetUnset($key)
41
    {
42
        unset($this->offset[$key]);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function count()
49
    {
50
        return count($this->offset);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getIterator()
57
    {
58
        return new \ArrayIterator($this->offset);
59
    }
60
}
61