Passed
Push — master ( 668c77...c11634 )
by Gilles
02:19
created

AttributeDTO::htmlspecialcharsDecode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPHtmlParser\DTO\Tag;
6
7
use stringEncode\Encode;
8
use stringEncode\Exception;
9
10
final class AttributeDTO
11
{
12
    /**
13
     * @var ?string
14
     */
15
    private $value;
16
17
    /**
18
     * @var bool
19
     */
20
    private $doubleQuote;
21
22 372
    public function __construct(array $values)
23
    {
24 372
        $this->value = $values['value'];
25 372
        $this->doubleQuote = $values['doubleQuote'] ?? true;
26 372
    }
27
28 306
    public function getValue(): ?string
29
    {
30 306
        return $this->value;
31
    }
32
33 135
    public function isDoubleQuote(): bool
34
    {
35 135
        return $this->doubleQuote;
36
    }
37
38 3
    public function htmlspecialcharsDecode(): void
39
    {
40 3
        if (!\is_null($this->value)) {
41 3
            $this->value = \htmlspecialchars_decode($this->value);
42
        }
43 3
    }
44
45
    /**
46
     * @throws Exception
47
     */
48 201
    public function encodeValue(Encode $encode)
49
    {
50 201
        $this->value = $encode->convert($this->value);
51 201
    }
52
}
53