Passed
Push — master ( 8fcbba...70d149 )
by Carsten
02:36
created

InputContainer::offsetUnset()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 6
1
<?php
2
namespace Germania\FormValidator;
3
4
use Psr\Container\ContainerInterface;
5
6
class InputContainer implements ContainerInterface, \ArrayAccess
7
{
8
9
    /**
10
     * @var array
11
     */
12
    public $data;
13
14
    /**
15
     * @param array $data Optional array
16
     */
17 7
    public function __construct( array $data = array() )
18
    {
19 7
        $this->data = $data;
20 7
    }
21
22
23
    /**
24
     * @implements ContainerInterface
25
     */
26 2
    public function get( $offset )
27
    {
28 2
        if ($this->offsetExists( $offset )) {
29 1
            return $this->data[ $offset ];
30
        }
31 1
        throw new NotFoundException;
32
    }
33
34
    /**
35
     * @implements ContainerInterface
36
     */
37 2
    public function has( $offset )
38
    {
39 2
        return $this->offsetExists( $offset );
40
    }
41
42
43
44
45
    /**
46
     * @implements ArrayAccess
47
     */
48 3
    public function offsetExists($offset)
49
    {
50 3
        return isset($this->data[ $offset ]);
51
    }
52
53
    /**
54
     * @implements ArrayAccess
55
     */
56
    public function offsetSet($offset, $value)
57
    {
58
        $this->data[ $offset ] = $value;
59
    }
60
61
    /**
62
     * @implements ArrayAccess
63
     */
64 2
    public function offsetGet($offset)
65
    {
66 2
        return $this->offsetExists( $offset ) ? $this->data[ $offset ] : null;
67
    }
68
69
    /**
70
     * @implements ArrayAccess
71
     */
72
    public function offsetUnset($offset)
73
    {
74
        if ($this->offsetExists($offset)) {
75
            unset($this->data[ $offset ]);
76
        }
77
    }
78
}
79