Passed
Push — master ( 382b98...cf0bb6 )
by Gilles
08:40 queued 01:24
created

RuleDTO::makeFromPrimitives()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 6
dl 0
loc 9
ccs 8
cts 8
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PHPHtmlParser\DTO\Selector;
6
7
final class RuleDTO
8
{
9
    /**
10
     * @var string
11
     */
12
    private $tag;
13
14
    /**
15
     * @var string
16
     */
17
    private $operator;
18
19
    /**
20
     * @var string|array|null
21
     */
22
    private $key;
23
24
    /**
25
     * @var string|array|null
26
     */
27
    private $value;
28
29
    /**
30
     * @var bool
31
     */
32
    private $noKey;
33
34
    /**
35
     * @var bool
36
     */
37
    private $alterNext;
38
39 348
    private function __construct(array $values)
40
    {
41 348
        $this->tag = $values['tag'];
42 348
        $this->operator = $values['operator'];
43 348
        $this->key = $values['key'];
44 348
        $this->value = $values['value'];
45 348
        $this->noKey = $values['noKey'];
46 348
        $this->alterNext = $values['alterNext'];
47 348
    }
48
49
    /**
50
     * @param string|array|null $key
51
     * @param string|array|null $value
52
     */
53 348
    public static function makeFromPrimitives(string $tag, string $operator, $key, $value, bool $noKey, bool $alterNext): RuleDTO
54
    {
55 348
        return new RuleDTO([
56 348
            'tag'       => $tag,
57 348
            'operator'  => $operator,
58 348
            'key'       => $key,
59 348
            'value'     => $value,
60 348
            'noKey'     => $noKey,
61 348
            'alterNext' => $alterNext,
62
        ]);
63
    }
64
65 336
    public function getTag(): string
66
    {
67 336
        return $this->tag;
68
    }
69
70 111
    public function getOperator(): string
71
    {
72 111
        return $this->operator;
73
    }
74
75
    /**
76
     * @return string|array|null
77
     */
78 342
    public function getKey()
79
    {
80 342
        return $this->key;
81
    }
82
83
    /**
84
     * @return string|array|null
85
     */
86 123
    public function getValue()
87
    {
88 123
        return $this->value;
89
    }
90
91 123
    public function isNoKey(): bool
92
    {
93 123
        return $this->noKey;
94
    }
95
96 333
    public function isAlterNext(): bool
97
    {
98 333
        return $this->alterNext;
99
    }
100
}
101