MagicAccess   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __unset() 0 3 1
A __set() 0 3 1
A __isset() 0 3 1
A __get() 0 3 1
1
<?php
2
3
/**
4
 * Bluz Framework Component
5
 *
6
 * @copyright Bluz PHP Team
7
 * @link      https://github.com/bluzphp/framework
8
 */
9
10
declare(strict_types=1);
11
12
namespace Bluz\Common\Container;
13
14
/**
15
 * Implements magic access to container
16
 *
17
 * @package  Bluz\Common
18
 * @author   Anton Shevchuk
19
 *
20
 * @method   void  doSetContainer(string $key, $value)
21
 * @method   mixed doGetContainer(string $key)
22
 * @method   bool  doContainsContainer(string $key)
23
 * @method   void  doDeleteContainer(string $key)
24
 */
25
trait MagicAccess
26
{
27
    /**
28
     * Magic alias for set() regular method
29
     *
30
     * @param string $key
31
     * @param  mixed  $value
32
     *
33
     * @return void
34
     */
35 16
    public function __set(string $key, $value): void
36
    {
37 16
        $this->doSetContainer($key, $value);
38 16
    }
39
40
    /**
41
     * Magic alias for get() regular method
42
     *
43
     * @param string $key
44
     *
45
     * @return mixed
46
     */
47 8
    public function __get(string $key)
48
    {
49 8
        return $this->doGetContainer($key);
50
    }
51
52
    /**
53
     * Magic alias for contains() regular method
54
     *
55
     * @param string $key
56
     *
57
     * @return bool
58
     */
59 3
    public function __isset(string $key): bool
60
    {
61 3
        return $this->doContainsContainer($key);
62
    }
63
64
    /**
65
     * Magic alias for delete() regular method
66
     *
67
     * @param string $key
68
     *
69
     * @return void
70
     */
71 3
    public function __unset(string $key): void
72
    {
73 3
        $this->doDeleteContainer($key);
74 3
    }
75
}
76