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

RegularAccess::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 regular 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 RegularAccess
25
{
26
    /**
27
     * Set key/value pair
28
     * @param  string $key
29
     * @param  mixed  $value
30
     * @return void
31
     */
32
    public function set($key, $value)
33
    {
34
        $this->doSetContainer($key, $value);
35
    }
36
37
    /**
38
     * Get value by key
39
     * @param  string $key
40
     * @return mixed
41
     */
42
    public function get($key)
43
    {
44
        return $this->doGetContainer($key);
45
    }
46
47
    /**
48
     * Check contains key in container
49
     * @param  string $key
50
     * @return bool
51
     */
52
    public function contains($key)
53
    {
54
        return $this->doContainsContainer($key);
55
    }
56
57
    /**
58
     * Delete value by key
59
     * @param  string $key
60
     * @return void
61
     */
62
    public function delete($key)
63
    {
64
        $this->doDeleteContainer($key);
65
    }
66
}
67