MagicAccess   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 51
ccs 8
cts 8
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __unset() 0 3 1
A __get() 0 3 1
A __isset() 0 3 1
A __set() 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\Container;
13
14
/**
15
 * Implements magic access to container
16
 *
17
 * @package  Bluz\Common
18
 * @author   Anton Shevchuk
19
 */
20
trait MagicAccess
21
{
22
    use Container;
23
24
    /**
25
     * Magic alias for set() regular method
26
     *
27
     * @param string $key
28
     * @param  mixed  $value
29
     *
30
     * @return void
31
     */
32 2
    public function __set(string $key, mixed $value): void
33
    {
34 2
        $this->doSetContainer($key, $value);
35
    }
36
37
    /**
38
     * Magic alias for get() regular method
39
     *
40
     * @param string $key
41
     *
42
     * @return mixed
43
     */
44 2
    public function __get(string $key): mixed
45
    {
46 2
        return $this->doGetContainer($key);
47
    }
48
49
    /**
50
     * Magic alias for contains() regular method
51
     *
52
     * @param string $key
53
     *
54
     * @return bool
55
     */
56 2
    public function __isset(string $key): bool
57
    {
58 2
        return $this->doContainsContainer($key);
59
    }
60
61
    /**
62
     * Magic alias for delete() regular method
63
     *
64
     * @param string $key
65
     *
66
     * @return void
67
     */
68 2
    public function __unset(string $key): void
69
    {
70 2
        $this->doDeleteContainer($key);
71
    }
72
}
73