Item   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 14
c 1
b 0
f 0
dl 0
loc 42
ccs 16
cts 16
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setValue() 0 4 1
A updateValue() 0 4 1
A getValue() 0 3 1
A getDefault() 0 3 1
A getKey() 0 3 1
A setData() 0 5 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