Completed
Pull Request — master (#2)
by Adam
01:53
created

Html::__callStatic()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace BestServedCold\HTMLBuilder;
4
5
use BestServedCold\HTMLBuilder\Html\Node,
6
    BestServedCold\HTMLBuilder\Html\Special,
7
    InvalidArgumentException;
8
9
/**
10
 * Class Html
11
 *
12
 * @package BestServedCold\HTMLBuilder
13
 * @method  static Node a(...$arguments)
14
 * @method  static Node abbr(...$arguments)
15
 * @method  static Node address(...$arguments)
16
 * @method  static Node area(...$arguments)
17
 * @method  static Node article(...$arguments)
18
 * @method  static Node aside(...$arguments)
19
 * @method  static Node audio(...$arguments)
20
 * @method  static Node b(...$arguments)
21
 * @method  static Node base(...$arguments)
22
 * @method  static Node bdi(...$arguments)
23
 * @method  static Node bdo(...$arguments)
24
 * @method  static Node blockquote(...$arguments)
25
 * @method  static Node body(...$arguments)
26
 * @method  static Node br(...$arguments)
27
 * @method  static Node button(...$arguments)
28
 * @method  static Node canvas(...$arguments)
29
 * @method  static Node caption(...$arguments)
30
 * @method  static Node cite(...$arguments)
31
 * @method  static Node code(...$arguments)
32
 * @method  static Node col(...$arguments)
33
 * @method  static Node colgroup(...$arguments)
34
 * @method  static Node datalist(...$arguments)
35
 * @method  static Node dd(...$arguments)
36
 * @method  static Node del(...$arguments)
37
 * @method  static Node details(...$arguments)
38
 * @method  static Node dfn(...$arguments)
39
 * @method  static Node dialog(...$arguments)
40
 * @method  static Node div(...$arguments)
41
 * @method  static Node dl(...$arguments)
42
 * @method  static Node dt(...$arguments)
43
 * @method  static Node em(...$arguments)
44
 * @method  static Node embed(...$arguments)
45
 * @method  static Node fieldset(...$arguments)
46
 * @method  static Node figcaption(...$arguments)
47
 * @method  static Node figure(...$arguments)
48
 * @method  static Node footer(...$arguments)
49
 * @method  static Node form(...$arguments)
50
 * @method  static Node h1(...$arguments)
51
 * @method  static Node h2(...$arguments)
52
 * @method  static Node h3(...$arguments)
53
 * @method  static Node h4(...$arguments)
54
 * @method  static Node h5(...$arguments)
55
 * @method  static Node h6(...$arguments)
56
 * @method  static Node head(...$arguments)
57
 * @method  static Node header(...$arguments)
58
 * @method  static Node hr(...$arguments)
59
 * @method  static Node html(...$arguments)
60
 * @method  static Node i(...$arguments)
61
 * @method  static Node iframe(...$arguments)
62
 * @method  static Node img(...$arguments)
63
 * @method  static Node input(...$arguments)
64
 * @method  static Node ins(...$arguments)
65
 * @method  static Node kbd(...$arguments)
66
 * @method  static Node keygen(...$arguments)
67
 * @method  static Node label(...$arguments)
68
 * @method  static Node legend(...$arguments)
69
 * @method  static Node li(...$arguments)
70
 * @method  static Node link(...$arguments)
71
 * @method  static Node main(...$arguments)
72
 * @method  static Node map(...$arguments)
73
 * @method  static Node mark(...$arguments)
74
 * @method  static Node menu(...$arguments)
75
 * @method  static Node menuitem(...$arguments)
76
 * @method  static Node meta(...$arguments)
77
 * @method  static Node meter(...$arguments)
78
 * @method  static Node nav(...$arguments)
79
 * @method  static Node noscript(...$arguments)
80
 * @method  static Node object(...$arguments)
81
 * @method  static Node ol(...$arguments)
82
 * @method  static Node optgroup(...$arguments)
83
 * @method  static Node option(...$arguments)
84
 * @method  static Node output(...$arguments)
85
 * @method  static Node p(...$arguments)
86
 * @method  static Node param(...$arguments)
87
 * @method  static Node picture(...$arguments)
88
 * @method  static Node pre(...$arguments)
89
 * @method  static Node progress(...$arguments)
90
 * @method  static Node q(...$arguments)
91
 * @method  static Node rp(...$arguments)
92
 * @method  static Node rt(...$arguments)
93
 * @method  static Node ruby(...$arguments)
94
 * @method  static Node s(...$arguments)
95
 * @method  static Node samp(...$arguments)
96
 * @method  static Node script(...$arguments)
97
 * @method  static Node section(...$arguments)
98
 * @method  static Node select(...$arguments)
99
 * @method  static Node small(...$arguments)
100
 * @method  static Node source(...$arguments)
101
 * @method  static Node span(...$arguments)
102
 * @method  static Node strong(...$arguments)
103
 * @method  static Node style(...$arguments)
104
 * @method  static Node sub(...$arguments)
105
 * @method  static Node summary(...$arguments)
106
 * @method  static Node sup(...$arguments)
107
 * @method  static Node table(...$arguments)
108
 * @method  static Node tbody(...$arguments)
109
 * @method  static Node td(...$arguments)
110
 * @method  static Node textarea(...$arguments)
111
 * @method  static Node tfoot(...$arguments)
112
 * @method  static Node th(...$arguments)
113
 * @method  static Node thead(...$arguments)
114
 * @method  static Node time(...$arguments)
115
 * @method  static Node title(...$arguments)
116
 * @method  static Node tr(...$arguments)
117
 * @method  static Node track(...$arguments)
118
 * @method  static Node u(...$arguments)
119
 * @method  static Node ul(...$arguments)
120
 * @method  static Node var(...$arguments)
121
 * @method  static Node video(...$arguments)
122
 * @method  static Node wbr(...$arguments)
123
 */
124
abstract class Html
125
{
126
    use Special;
127
    
128
    /**
129
     * @var array $elements
130
     */
131
    private  static $elements = [
132
        'a',
133
        'abbr',
134
        'address',
135
        'area',
136
        'article',
137
        'aside',
138
        'audio',
139
        'b',
140
        'base',
141
        'bdi',
142
        'bdo',
143
        'blockquote',
144
        'body',
145
        'br',
146
        'button',
147
        'canvas',
148
        'caption',
149
        'cite',
150
        'code',
151
        'col',
152
        'colgroup',
153
        'datalist',
154
        'dd',
155
        'del',
156
        'details',
157
        'dfn',
158
        'dialog',
159
        'div',
160
        'dl',
161
        'dt',
162
        'em',
163
        'embed',
164
        'fieldset',
165
        'figcaption',
166
        'figure',
167
        'footer',
168
        'form',
169
        'h1',
170
        'h2',
171
        'h3',
172
        'h4',
173
        'h5',
174
        'h6',
175
        'head',
176
        'header',
177
        'hr',
178
        'html',
179
        'i',
180
        'iframe',
181
        'img',
182
        'input',
183
        'ins',
184
        'kbd',
185
        'keygen',
186
        'label',
187
        'legend',
188
        'li',
189
        'link',
190
        'main',
191
        'map',
192
        'mark',
193
        'menu',
194
        'menuitem',
195
        'meta',
196
        'meter',
197
        'nav',
198
        'noscript',
199
        'object',
200
        'ol',
201
        'optgroup',
202
        'option',
203
        'output',
204
        'p',
205
        'param',
206
        'picture',
207
        'pre',
208
        'progress',
209
        'q',
210
        'rp',
211
        'rt',
212
        'ruby',
213
        's',
214
        'samp',
215
        'script',
216
        'section',
217
        'select',
218
        'small',
219
        'source',
220
        'span',
221
        'strong',
222
        'style',
223
        'sub',
224
        'summary',
225
        'sup',
226
        'table',
227
        'tbody',
228
        'td',
229
        'textarea',
230
        'tfoot',
231
        'th',
232
        'thead',
233
        'time',
234
        'title',
235
        'tr',
236
        'track',
237
        'u',
238
        'ul',
239
        'var',
240
        'video',
241
        'wbr'
242
    ];
243
244
    /**
245
     * @var array $voidElements
246
     */
247
    private  static $voidElements = [
248
        'area',
249
        'base',
250
        'br',
251
        'col',
252
        'command',
253
        'embed',
254
        'hr',
255
        'img',
256
        'input',
257
        'keygen',
258
        'link',
259
        'meta',
260
        'param',
261
        'source',
262
        'track',
263
        'wbr'
264
    ];
265
    
266
    /**
267
     *  Static over loader
268
     *
269
     * @param  string $name
270
     * @param  array  $arguments
271
     * @return Node
272
     * @throws InvalidArgumentException
273
     */
274
    public  static function __callStatic($name, $arguments)
275
    {
276
        if (in_array($name, self::$elements)) {
277
            return new Node($name, $arguments, in_array($name, self::$voidElements));
278
        }
279
280
        throw new InvalidArgumentException('Method [' . $name . '] does not exist in context [' . self::class . '].');
281
    }
282
}
283