Passed
Push — master ( 4d2a94...142804 )
by Sebastian
03:29
created

ArrayAccessTrait::offsetSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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
     * @ignore
84
     */
85 18
    public function offsetSet($key, $value)
86
    {
87 18
        $this->set($key, $value);
88 18
    }
89
90
    /**
91
     * Delete.
92
     *
93
     * @param string $key
94
     *
95
     * @return mixed
96
     *
97
     * @ignore
98
     */
99 6
    public function offsetUnset($key)
100
    {
101 6
        return $this->delete($key);
102
    }
103
}
104