Container   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 53
ccs 16
cts 18
cp 0.8889
rs 10
c 0
b 0
f 0
wmc 9

7 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A has() 0 3 1
A bound() 0 3 1
A append() 0 3 1
A bind() 0 7 2
A get() 0 7 2
A rebind() 0 3 1
1
<?php
2
3
namespace Sanderdekroon\Parlant;
4
5
class Container
6
{
7
8
    private $registry = [];
9
10
11 35
    public function bind($key, $data)
12
    {
13 35
        if ($this->bound($key)) {
14 4
            return $this->rebind($key, $data);
15
        }
16
17 35
        return $this->registry[$key] = $data;
18
    }
19
20
21 14
    public function append($key, $data)
22
    {
23 14
        return $this->registry[$key][] = $data;
24
    }
25
26
27 28
    public function get($key)
28
    {
29 28
        if (!$this->bound($key)) {
30 11
            return null;
31
        }
32
33 28
        return $this->registry[$key];
34
    }
35
36
37 28
    public function all()
38
    {
39 28
        return $this->registry;
40
    }
41
42
43
    public function has($key)
44
    {
45
        return $this->bound($key);
46
    }
47
48
49 35
    private function bound($key)
50
    {
51 35
        return array_key_exists($key, $this->registry);
52
    }
53
54
55 4
    private function rebind($key, $data)
56
    {
57 4
        return $this->registry[$key] = $data;
58
    }
59
}
60