Element::isVoid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
c 1
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Internet\Html;
4
5
use BestServedCold\PhalueObjects\VOString;
6
7
/**
8
 * Class Element
9
 *
10
 * @package BestServedCold\PhalueObjects\Internet\Html
11
 */
12
class Element extends VOString
13
{
14
    /**
15
     * @var array $elements
16
     */
17
    private $elements = [
18
        'a',
19
        'abbr',
20
        'address',
21
        'area',
22
        'article',
23
        'aside',
24
        'audio',
25
        'b',
26
        'base',
27
        'bdi',
28
        'bdo',
29
        'blockquote',
30
        'body',
31
        'br',
32
        'button',
33
        'canvas',
34
        'caption',
35
        'cite',
36
        'code',
37
        'col',
38
        'colgroup',
39
        'datalist',
40
        'dd',
41
        'del',
42
        'details',
43
        'dfn',
44
        'dialog',
45
        'div',
46
        'dl',
47
        'dt',
48
        'em',
49
        'embed',
50
        'fieldset',
51
        'figcaption',
52
        'figure',
53
        'footer',
54
        'form',
55
        'h1',
56
        'h2',
57
        'h3',
58
        'h4',
59
        'h5',
60
        'h6',
61
        'head',
62
        'header',
63
        'hr',
64
        'html',
65
        'i',
66
        'iframe',
67
        'img',
68
        'input',
69
        'ins',
70
        'kbd',
71
        'keygen',
72
        'label',
73
        'legend',
74
        'li',
75
        'link',
76
        'main',
77
        'map',
78
        'mark',
79
        'menu',
80
        'menuitem',
81
        'meta',
82
        'meter',
83
        'nav',
84
        'noscript',
85
        'object',
86
        'ol',
87
        'optgroup',
88
        'option',
89
        'output',
90
        'p',
91
        'param',
92
        'picture',
93
        'pre',
94
        'progress',
95
        'q',
96
        'rp',
97
        'rt',
98
        'ruby',
99
        's',
100
        'samp',
101
        'script',
102
        'section',
103
        'select',
104
        'small',
105
        'source',
106
        'span',
107
        'strong',
108
        'style',
109
        'sub',
110
        'summary',
111
        'sup',
112
        'table',
113
        'tbody',
114
        'td',
115
        'textarea',
116
        'tfoot',
117
        'th',
118
        'thead',
119
        'time',
120
        'title',
121
        'tr',
122
        'track',
123
        'u',
124
        'ul',
125
        'var',
126
        'video',
127
        'wbr'
128
    ];
129
130
    /**
131
     * @var array $voidElements
132
     */
133
    private $voidElements = [
134
        'area',
135
        'base',
136
        'br',
137
        'col',
138
        'command',
139
        'embed',
140
        'hr',
141
        'img',
142
        'input',
143
        'keygen',
144
        'link',
145
        'meta',
146
        'param',
147
        'source',
148
        'track',
149
        'wbr'
150
    ];
151
152
    /**
153
     * Element constructor.
154
     *
155
     * @param $value
156
     */
157 3
    public function __construct($value)
158
    {
159 3
        if (!in_array($value, $this->elements)) {
160 1
            throw new \InvalidArgumentException('['.$value.'] is not a valid HTML element');
161
        }
162
163 3
        parent::__construct($value);
164 3
    }
165
166
    /**
167
     * @return bool
168
     */
169 1
    public function isVoid()
170
    {
171 1
        return in_array($this->getValue(), $this->voidElements);
172
    }
173
}
174