MagicAccess::__set()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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