ArrayAccessTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 5
c 0
b 0
f 0
dl 0
loc 86
ccs 9
cts 9
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A offsetGet() 0 3 1
A offsetUnset() 0 3 1
A offsetSet() 0 3 1
1
<?php
2
3
/**
4
 * Linna Framework.
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Container;
13
14
/**
15
 * Array Access Trait
16
 * Provide to DIContainer the possibility to retrive values using array notation.
17
 */
18
trait ArrayAccessTrait
19
{
20
    /**
21
     * Express Requirements by Abstract Methods.
22
     *
23
     * @param string $key
24
     */
25
    abstract public function has($key);
26
27
    /**
28
     * Express Requirements by Abstract Methods.
29
     *
30
     * @param string $key
31
     */
32
    abstract public function get($key);
33
34
    /**
35
     * Express Requirements by Abstract Methods.
36
     *
37
     * @param string $key
38
     * @param mixed  $value
39
     */
40
    abstract public function set($key, $value);
41
42
    /**
43
     * Express Requirements by Abstract Methods.
44
     *
45
     * @param string $key
46
     */
47
    abstract public function delete($key): bool;
48
49
    /**
50
     * Check.
51
     *
52
     * @param string $key
53
     *
54
     * @return bool
55
     *
56
     * @ignore
57
     */
58 12
    public function offsetExists($key)
59
    {
60 12
        return $this->has($key);
61
    }
62
63
    /**
64
     * Get.
65
     *
66
     * @param string $key
67
     *
68
     * @return mixed
69
     *
70
     * @ignore
71
     */
72 12
    public function offsetGet($key)
73
    {
74 12
        return $this->get($key);
75
    }
76
77
    /**
78
     * Store.
79
     *
80
     * @param string $key
81
     * @param mixed  $value
82
     *
83
     * @return void
84
     *
85
     * @ignore
86
     */
87 18
    public function offsetSet($key, $value)
88
    {
89 18
        $this->set($key, $value);
90 18
    }
91
92
    /**
93
     * Delete.
94
     *
95
     * @param string $key
96
     *
97
     * @return mixed
98
     *
99
     * @ignore
100
     */
101 6
    public function offsetUnset($key)
102
    {
103 6
        return $this->delete($key);
104
    }
105
}
106