Passed
Push — master ( 3624d1...36fc6d )
by Gerrit
02:07
created

ArgumentContext::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\SymfonyGenerics\Arguments;
14
15
use Addiks\SymfonyGenerics\Arguments\ArgumentContextInterface;
16
use Webmozart\Assert\Assert;
17
18
final class ArgumentContext implements ArgumentContextInterface
19
{
20
21
    /**
22
     * @var array<string, mixed>
23
     */
24
    private $variables = array();
25
26 1
    public function set(string $key, $value): void
27
    {
28 1
        $this->variables[$key] = $value;
29 1
    }
30
31 1
    public function has(string $key): bool
32
    {
33 1
        return array_key_exists($key, $this->variables);
34
    }
35
36 2
    public function get(string $key)
37
    {
38 2
        Assert::keyExists($this->variables, $key);
39
40 1
        return $this->variables[$key];
41
    }
42
43 1
    public function clear(): void
44
    {
45 1
        $this->variables = array();
46 1
    }
47
48
}
49