Passed
Push — main ( 8599f1...f44baa )
by Thierry
06:14
created

DatabagContext::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Jaxon\App\Databag;
4
5
class DatabagContext
6
{
7
    /**
8
     * The constructor
9
     *
10
     * @param Databag $xDatabag
11
     * @param string $sName
12
     */
13
    public function __construct(protected Databag $xDatabag, protected string $sName)
14
    {}
15
16
    /**
17
     * @param string $sKey
18
     * @param mixed $xValue
19
     *
20
     * @return void
21
     */
22
    public function set(string $sKey, $xValue): void
23
    {
24
        $this->xDatabag->set($this->sName, $sKey, $xValue);
25
    }
26
27
    /**
28
     * @param string $sKey
29
     * @param mixed $xValue
30
     *
31
     * @return void
32
     */
33
    public function new(string $sKey, $xValue): void
34
    {
35
        $this->xDatabag->new($this->sName, $sKey, $xValue);
36
    }
37
38
    /**
39
     * @param string $sKey
40
     * @param mixed $xValue
41
     *
42
     * @return mixed
43
     */
44
    public function get(string $sKey, $xValue = null): mixed
45
    {
46
        return $this->xDatabag->get($this->sName, $sKey, $xValue);
47
    }
48
49
    /**
50
     * @return self
51
     */
52
    public function clear(): self
53
    {
54
        $this->xDatabag->clear($this->sName);
55
        return $this;
56
    }
57
}
58