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

InputContainer   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 61.9%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 1
dl 0
loc 73
ccs 13
cts 21
cp 0.619
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 7 2
A has() 0 4 1
A offsetExists() 0 4 1
A offsetSet() 0 4 1
A offsetGet() 0 4 2
A offsetUnset() 0 6 2
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