Completed
Pull Request — master (#399)
by Anton
04:15
created

MagicAccess::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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