Completed
Push — master ( 8c9478...0f7d17 )
by Adam
02:25
created

Element::isVoid()   A

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