Item::setValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace kalanis\kw_templates\Template;
4
5
6
class Item
7
{
8
    protected string $key = '';
9
    protected string $default = '';
10
    protected ?string $value = null;
11
12 3
    public function setData(string $key, string $default = ''): self
13
    {
14 3
        $this->key = $key;
15 3
        $this->default = $default;
16 3
        return $this;
17
    }
18
19 3
    public function setValue(?string $value): self
20
    {
21 3
        $this->value = $value;
22 3
        return $this;
23
    }
24
25
    /**
26
     * @param bool|float|int|string|null ...$arg
27
     * @return $this
28
     */
29 1
    public function updateValue(...$arg): self
30
    {
31 1
        $this->value = sprintf($this->getValue(), ...$arg);
32 1
        return $this;
33
    }
34
35 3
    public function getKey(): string
36
    {
37 3
        return $this->key ;
38
    }
39
40 1
    public function getDefault(): string
41
    {
42 1
        return $this->default;
43
    }
44
45 3
    public function getValue(): string
46
    {
47 3
        return $this->value ?? $this->default ;
48
    }
49
}
50