@@ -149,13 +149,13 @@ discard block |
||
149 | 149 | */ |
150 | 150 | public function &__get($tagName) |
151 | 151 | { |
152 | - $getDocument[ $tagName ] = null; |
|
152 | + $getDocument[$tagName] = null; |
|
153 | 153 | |
154 | 154 | if (in_array($tagName, ['html', 'head', 'body', 'title'])) { |
155 | - $getDocument[ $tagName ] = $this->getElementsByTagName($tagName)->item(0); |
|
155 | + $getDocument[$tagName] = $this->getElementsByTagName($tagName)->item(0); |
|
156 | 156 | } |
157 | 157 | |
158 | - return $getDocument[ $tagName ]; |
|
158 | + return $getDocument[$tagName]; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | // ------------------------------------------------------------------------ |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $output = $beautifier->format($output); |
279 | 279 | } |
280 | 280 | |
281 | - return (string) $output; |
|
281 | + return (string)$output; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | // ------------------------------------------------------------------------ |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | |
444 | 444 | // Has inline script element |
445 | 445 | if (preg_match_all('/<script((?:(?!src=).)*?)>(.*?)<\/script>/smix', $source, $matches)) { |
446 | - if (isset($matches[ 2 ])) { |
|
447 | - foreach ($matches[ 2 ] as $match) { |
|
446 | + if (isset($matches[2])) { |
|
447 | + foreach ($matches[2] as $match) { |
|
448 | 448 | $script = trim($match); |
449 | 449 | $this->bodyScriptContent[md5($script)] = $script . PHP_EOL; |
450 | 450 | } |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | foreach ($metas as $meta) { |
462 | 462 | $attributes = []; |
463 | 463 | foreach ($meta->attributes as $name => $attribute) { |
464 | - $attributes[ $name ] = $attribute->nodeValue; |
|
464 | + $attributes[$name] = $attribute->nodeValue; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | $this->metaNodes->createElement($attributes); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | foreach ($links as $link) { |
474 | 474 | $attributes = []; |
475 | 475 | foreach ($link->attributes as $name => $attribute) { |
476 | - $attributes[ $name ] = $attribute->nodeValue; |
|
476 | + $attributes[$name] = $attribute->nodeValue; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | $this->linkNodes->createElement($attributes); |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | foreach ($scripts as $script) { |
486 | 486 | $attributes = []; |
487 | 487 | foreach ($script->attributes as $name => $attribute) { |
488 | - $attributes[ $name ] = $attribute->nodeValue; |
|
488 | + $attributes[$name] = $attribute->nodeValue; |
|
489 | 489 | } |
490 | 490 | } |
491 | 491 | |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | foreach ($scripts as $script) { |
494 | 494 | $attributes = []; |
495 | 495 | foreach ($script->attributes as $name => $attribute) { |
496 | - $attributes[ $name ] = $attribute->nodeValue; |
|
496 | + $attributes[$name] = $attribute->nodeValue; |
|
497 | 497 | } |
498 | 498 | |
499 | - if($script->textContent == '') { |
|
499 | + if ($script->textContent == '') { |
|
500 | 500 | $this->bodyScriptNodes->createElement($attributes); |
501 | 501 | } |
502 | 502 | } |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | |
506 | 506 | // Has inline style Element |
507 | 507 | if (preg_match_all('/((<[\\s\\/]*style\\b[^>]*>)([^>]*)(<\\/style>))/i', $source, $matches)) { |
508 | - if (isset($matches[ 3 ])) { |
|
509 | - foreach ($matches[ 3 ] as $match) { |
|
508 | + if (isset($matches[3])) { |
|
509 | + foreach ($matches[3] as $match) { |
|
510 | 510 | $style = trim($match); |
511 | 511 | $this->styleContent[md5($style)] = $style . PHP_EOL; |
512 | 512 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | |
518 | 518 | $codes = $DOMXPath->query('//code'); |
519 | 519 | foreach ($codes as $code) { |
520 | - if($code->textContent == '') { |
|
520 | + if ($code->textContent == '') { |
|
521 | 521 | $code = str_replace(['{{php', '/php}}'], ['<?php', '?>'], $code->textContent); |
522 | 522 | $code = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\r\n", $code); |
523 | 523 | $source = str_replace($code, htmlentities($code), $source); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function __construct(Document $ownerDocument) |
38 | 38 | { |
39 | - $this->ownerDocument =& $ownerDocument; |
|
39 | + $this->ownerDocument = & $ownerDocument; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // ------------------------------------------------------------------------ |
@@ -38,7 +38,7 @@ |
||
38 | 38 | */ |
39 | 39 | public function __construct(Document $ownerDocument) |
40 | 40 | { |
41 | - $this->ownerDocument =& $ownerDocument; |
|
41 | + $this->ownerDocument = & $ownerDocument; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // ------------------------------------------------------------------------ |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | $selector = trim($selector); |
84 | 84 | |
85 | 85 | if (array_key_exists($selector, $this->compiledExpressions)) { |
86 | - $paths[] = $this->compiledExpressions[ $selector ]; |
|
86 | + $paths[] = $this->compiledExpressions[$selector]; |
|
87 | 87 | |
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | - $this->compiledExpressions[ $selector ] = $this->fetchCssExpression($selector); |
|
91 | + $this->compiledExpressions[$selector] = $this->fetchCssExpression($selector); |
|
92 | 92 | |
93 | - $paths[] = $this->compiledExpressions[ $selector ]; |
|
93 | + $paths[] = $this->compiledExpressions[$selector]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | return implode('|', $paths); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | if ($pos !== false) { |
116 | 116 | $property = substr($selector, $pos + 2); |
117 | 117 | $property = $this->fetchCssProperty($property); |
118 | - $property = $this->parseCssProperty($property[ 'name' ], $property[ 'args' ]); |
|
118 | + $property = $this->parseCssProperty($property['name'], $property['args']); |
|
119 | 119 | |
120 | 120 | $selector = substr($selector, 0, $pos); |
121 | 121 | } |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | while (count($segments) > 0) { |
133 | 133 | $expression .= $this->generateExpression($segments, $prefix); |
134 | 134 | |
135 | - $selector = trim(substr($selector, strlen($segments[ 'selector' ]))); |
|
136 | - $prefix = isset($segments[ 'rel' ]) ? '/' : '//'; |
|
135 | + $selector = trim(substr($selector, strlen($segments['selector']))); |
|
136 | + $prefix = isset($segments['rel']) ? '/' : '//'; |
|
137 | 137 | |
138 | 138 | if ($selector === '') { |
139 | 139 | break; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | if (preg_match($regexp, $property, $segments)) { |
168 | 168 | $result = []; |
169 | 169 | |
170 | - $result[ 'name' ] = $segments[ 'name' ]; |
|
171 | - $result[ 'args' ] = isset($segments[ 'args' ]) ? explode('|', $segments[ 'args' ]) : []; |
|
170 | + $result['name'] = $segments['name']; |
|
171 | + $result['args'] = isset($segments['args']) ? explode('|', $segments['args']) : []; |
|
172 | 172 | |
173 | 173 | return $result; |
174 | 174 | } |
@@ -239,21 +239,21 @@ discard block |
||
239 | 239 | $regexp = '/' . $tag . $id . $classes . $attrs . $pseudo . $rel . '/is'; |
240 | 240 | |
241 | 241 | if (preg_match($regexp, $selector, $segments)) { |
242 | - if ($segments[ 0 ] === '') { |
|
242 | + if ($segments[0] === '') { |
|
243 | 243 | throw new RuntimeException('HTML_E_INVALID_SELECTOR'); |
244 | 244 | } |
245 | 245 | |
246 | - $result[ 'selector' ] = $segments[ 0 ]; |
|
247 | - $result[ 'tag' ] = (isset($segments[ 'tag' ]) and $segments[ 'tag' ] !== '') ? $segments[ 'tag' ] : '*'; |
|
246 | + $result['selector'] = $segments[0]; |
|
247 | + $result['tag'] = (isset($segments['tag']) and $segments['tag'] !== '') ? $segments['tag'] : '*'; |
|
248 | 248 | |
249 | 249 | // if the id attribute specified |
250 | - if (isset($segments[ 'id' ]) and $segments[ 'id' ] !== '') { |
|
251 | - $result[ 'id' ] = $segments[ 'id' ]; |
|
250 | + if (isset($segments['id']) and $segments['id'] !== '') { |
|
251 | + $result['id'] = $segments['id']; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | // if the attributes specified |
255 | - if (isset($segments[ 'attrs' ])) { |
|
256 | - $attributes = trim($segments[ 'attrs' ], '[]'); |
|
255 | + if (isset($segments['attrs'])) { |
|
256 | + $attributes = trim($segments['attrs'], '[]'); |
|
257 | 257 | $attributes = explode('][', $attributes); |
258 | 258 | |
259 | 259 | foreach ($attributes as $attribute) { |
@@ -261,35 +261,35 @@ discard block |
||
261 | 261 | list($name, $value) = array_pad(explode('=', $attribute, 2), 2, null); |
262 | 262 | |
263 | 263 | // equal null if specified only the attribute name |
264 | - $result[ 'attributes' ][ $name ] = is_string($value) ? trim($value, '\'"') : null; |
|
264 | + $result['attributes'][$name] = is_string($value) ? trim($value, '\'"') : null; |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | 269 | // if the class attribute specified |
270 | - if (isset($segments[ 'classes' ])) { |
|
271 | - $classes = trim($segments[ 'classes' ], '.'); |
|
270 | + if (isset($segments['classes'])) { |
|
271 | + $classes = trim($segments['classes'], '.'); |
|
272 | 272 | $classes = explode('.', $classes); |
273 | 273 | |
274 | 274 | foreach ($classes as $class) { |
275 | 275 | if ($class !== '') { |
276 | - $result[ 'classes' ][] = $class; |
|
276 | + $result['classes'][] = $class; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | 281 | // if the pseudo class specified |
282 | - if (isset($segments[ 'pseudo' ]) and $segments[ 'pseudo' ] !== '') { |
|
283 | - $result[ 'pseudo' ] = $segments[ 'pseudo' ]; |
|
282 | + if (isset($segments['pseudo']) and $segments['pseudo'] !== '') { |
|
283 | + $result['pseudo'] = $segments['pseudo']; |
|
284 | 284 | |
285 | - if (isset($segments[ 'expr' ]) and $segments[ 'expr' ] !== '') { |
|
286 | - $result[ 'expr' ] = $segments[ 'expr' ]; |
|
285 | + if (isset($segments['expr']) and $segments['expr'] !== '') { |
|
286 | + $result['expr'] = $segments['expr']; |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | |
290 | 290 | // if it is a direct descendant |
291 | - if (isset($segments[ 'rel' ])) { |
|
292 | - $result[ 'rel' ] = $segments[ 'rel' ]; |
|
291 | + if (isset($segments['rel'])) { |
|
292 | + $result['rel'] = $segments['rel']; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | return $result; |
@@ -312,39 +312,39 @@ discard block |
||
312 | 312 | */ |
313 | 313 | private function generateExpression($segments, $prefix = '//') |
314 | 314 | { |
315 | - $tagName = isset($segments[ 'tag' ]) ? $segments[ 'tag' ] : '*'; |
|
315 | + $tagName = isset($segments['tag']) ? $segments['tag'] : '*'; |
|
316 | 316 | |
317 | 317 | $attributes = []; |
318 | 318 | |
319 | 319 | // if the id attribute specified |
320 | - if (isset($segments[ 'id' ])) { |
|
321 | - $attributes[] = sprintf('@id="%s"', $segments[ 'id' ]); |
|
320 | + if (isset($segments['id'])) { |
|
321 | + $attributes[] = sprintf('@id="%s"', $segments['id']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | // if the class attribute specified |
325 | - if (isset($segments[ 'classes' ])) { |
|
326 | - foreach ($segments[ 'classes' ] as $class) { |
|
325 | + if (isset($segments['classes'])) { |
|
326 | + foreach ($segments['classes'] as $class) { |
|
327 | 327 | $attributes[] = sprintf('contains(concat(" ", normalize-space(@class), " "), " %s ")', $class); |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | 331 | // if the attributes specified |
332 | - if (isset($segments[ 'attributes' ])) { |
|
333 | - foreach ($segments[ 'attributes' ] as $name => $value) { |
|
332 | + if (isset($segments['attributes'])) { |
|
333 | + foreach ($segments['attributes'] as $name => $value) { |
|
334 | 334 | $attributes[] = $this->fetchCssAttributeSelector($name, $value); |
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | 338 | // if the pseudo class specified |
339 | - if (isset($segments[ 'pseudo' ])) { |
|
340 | - $expression = isset($segments[ 'expr' ]) ? trim($segments[ 'expr' ]) : ''; |
|
339 | + if (isset($segments['pseudo'])) { |
|
340 | + $expression = isset($segments['expr']) ? trim($segments['expr']) : ''; |
|
341 | 341 | |
342 | 342 | $parameters = explode(',', $expression); |
343 | 343 | |
344 | - $attributes[] = $this->fetchCssPseudoSelector($segments[ 'pseudo' ], $parameters, $tagName); |
|
344 | + $attributes[] = $this->fetchCssPseudoSelector($segments['pseudo'], $parameters, $tagName); |
|
345 | 345 | } |
346 | 346 | |
347 | - if (count($attributes) === 0 and ! isset($segments[ 'tag' ])) { |
|
347 | + if (count($attributes) === 0 and ! isset($segments['tag'])) { |
|
348 | 348 | throw new InvalidArgumentException( |
349 | 349 | 'The array of segments should contain the name of the tag or at least one attribute' |
350 | 350 | ); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | ? sprintf('[(%s)]', implode(') and (', $attributes)) |
358 | 358 | : sprintf( |
359 | 359 | '[%s]', |
360 | - $attributes[ 0 ] |
|
360 | + $attributes[0] |
|
361 | 361 | ); |
362 | 362 | } |
363 | 363 | |
@@ -449,26 +449,26 @@ discard block |
||
449 | 449 | $xpath = sprintf( |
450 | 450 | '(name()="%s") and (%s)', |
451 | 451 | $tagName, |
452 | - $this->fetchCssPseudoNthSelector($parameters[ 0 ]) |
|
452 | + $this->fetchCssPseudoNthSelector($parameters[0]) |
|
453 | 453 | ); |
454 | 454 | $tagName = '*'; |
455 | 455 | |
456 | 456 | return $xpath; |
457 | 457 | break; |
458 | 458 | case 'contains': |
459 | - $string = trim($parameters[ 0 ], ' \'"'); |
|
460 | - $caseSensitive = isset($parameters[ 1 ]) and (trim($parameters[ 1 ]) === 'true'); |
|
459 | + $string = trim($parameters[0], ' \'"'); |
|
460 | + $caseSensitive = isset($parameters[1]) and (trim($parameters[1]) === 'true'); |
|
461 | 461 | |
462 | 462 | return $this->fetchCssPseudoContainsSelector($string, $caseSensitive); |
463 | 463 | break; |
464 | 464 | case 'has': |
465 | - return $this->fetchCssExpression($parameters[ 0 ], './/'); |
|
465 | + return $this->fetchCssExpression($parameters[0], './/'); |
|
466 | 466 | break; |
467 | 467 | case 'not': |
468 | - return sprintf('not($this->%s)', $this->fetchCssExpression($parameters[ 0 ], '')); |
|
468 | + return sprintf('not($this->%s)', $this->fetchCssExpression($parameters[0], '')); |
|
469 | 469 | break; |
470 | 470 | case 'nth-of-type': |
471 | - return $this->fetchCssPseudoNthSelector($parameters[ 0 ]); |
|
471 | + return $this->fetchCssPseudoNthSelector($parameters[0]); |
|
472 | 472 | break; |
473 | 473 | case 'empty': |
474 | 474 | return 'count(descendant::*) = 0'; |
@@ -516,10 +516,10 @@ discard block |
||
516 | 516 | } |
517 | 517 | |
518 | 518 | if (preg_match("/^(?P<mul>[0-9]?n)(?:(?P<sign>\+|\-)(?P<pos>[0-9]+))?$/is", $expression, $segments)) { |
519 | - if (isset($segments[ 'mul' ])) { |
|
520 | - $multiplier = $segments[ 'mul' ] === 'n' ? 1 : trim($segments[ 'mul' ], 'n'); |
|
521 | - $sign = (isset($segments[ 'sign' ]) and $segments[ 'sign' ] === '+') ? '-' : '+'; |
|
522 | - $position = isset($segments[ 'pos' ]) ? $segments[ 'pos' ] : 0; |
|
519 | + if (isset($segments['mul'])) { |
|
520 | + $multiplier = $segments['mul'] === 'n' ? 1 : trim($segments['mul'], 'n'); |
|
521 | + $sign = (isset($segments['sign']) and $segments['sign'] === '+') ? '-' : '+'; |
|
522 | + $position = isset($segments['pos']) ? $segments['pos'] : 0; |
|
523 | 523 | |
524 | 524 | return sprintf( |
525 | 525 | '(position() %s %d) mod %d = 0 and position() >= %d', |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | $tempScriptElements = []; |
140 | 140 | |
141 | 141 | if (preg_match_all('/<script\b[^>]*>([\s\S]*?)<\/script>/mi', $source, $matches)) { |
142 | - $tempScriptElements = $matches[ 0 ]; |
|
142 | + $tempScriptElements = $matches[0]; |
|
143 | 143 | |
144 | - foreach ($matches[ 0 ] as $i => $match) { |
|
144 | + foreach ($matches[0] as $i => $match) { |
|
145 | 145 | $source = str_replace($match, '<script>' . ($i + 1) . '</script>', $source); |
146 | 146 | } |
147 | 147 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | $source, |
161 | 161 | $matches |
162 | 162 | )) { |
163 | - $tempInlineElements = $matches[ 0 ]; |
|
163 | + $tempInlineElements = $matches[0]; |
|
164 | 164 | |
165 | - foreach ($matches[ 0 ] as $i => $match) { |
|
165 | + foreach ($matches[0] as $i => $match) { |
|
166 | 166 | $source = str_replace($match, 'ᐃ' . ($i + 1) . 'ᐃ', $source); |
167 | 167 | } |
168 | 168 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | foreach ($patterns as $pattern => $rule) { |
197 | 197 | if ($match = preg_match($pattern, $source, $matches)) { |
198 | 198 | if (function_exists('mb_substr')) { |
199 | - $source = mb_substr($source, mb_strlen($matches[ 0 ])); |
|
199 | + $source = mb_substr($source, mb_strlen($matches[0])); |
|
200 | 200 | } else { |
201 | - $source = substr($source, strlen($matches[ 0 ])); |
|
201 | + $source = substr($source, strlen($matches[0])); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | if ($rule === static::MATCH_DISCARD) { |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $indentationLevel = 0; |
221 | 221 | } |
222 | 222 | |
223 | - $output .= str_repeat($this->indentCharacter, $indentationLevel) . $matches[ 0 ] . "\n"; |
|
223 | + $output .= str_repeat($this->indentCharacter, $indentationLevel) . $matches[0] . "\n"; |
|
224 | 224 | |
225 | 225 | break; |
226 | 226 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | if ( ! empty($value)) { |
70 | 70 | |
71 | 71 | $hash = md5($value); |
72 | - return (bool) in_array($hash, $this->hashes); |
|
72 | + return (bool)in_array($hash, $this->hashes); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return false; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | if ( ! empty($value)) { |
88 | 88 | |
89 | 89 | $hash = md5($value); |
90 | - if(!in_array($hash, $this->hashes)) { |
|
90 | + if ( ! in_array($hash, $this->hashes)) { |
|
91 | 91 | parent::append($value); |
92 | 92 | $this->hashes[] = $hash; |
93 | 93 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | if (in_array($this->tagName, $selfClosingTags)) { |
102 | 102 | $attr = $this->attributes; |
103 | - unset($attr[ 'realpath' ]); |
|
103 | + unset($attr['realpath']); |
|
104 | 104 | |
105 | 105 | if ($this->hasAttributes()) { |
106 | 106 | return '<' . $this->tagName . ' ' . trim($this->attributes->__toString()) . '>'; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | public function open() |
146 | 146 | { |
147 | 147 | $attr = $this->attributes; |
148 | - unset($attr[ 'realpath' ]); |
|
148 | + unset($attr['realpath']); |
|
149 | 149 | |
150 | 150 | if ($this->hasAttributes()) { |
151 | 151 | return '<' . $this->tagName . ' ' . trim($this->attributes->__toString()) . '>'; |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | |
44 | 44 | foreach ($value as $style) { |
45 | 45 | if (preg_match_all("/(.*)(: )(.*)/", $style, $match)) { |
46 | - $this->addAttributeStyle($match[ 1 ][ 0 ], $match[ 3 ][ 0 ]); |
|
46 | + $this->addAttributeStyle($match[1][0], $match[3][0]); |
|
47 | 47 | } elseif (preg_match_all("/(.*)(:)(.*)/", $style, $match)) { |
48 | - $this->addAttributeStyle($match[ 1 ][ 0 ], $match[ 3 ][ 0 ]); |
|
48 | + $this->addAttributeStyle($match[1][0], $match[3][0]); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } elseif (is_string($value)) { |
52 | - $this->storage[ $name ] = trim($value); |
|
52 | + $this->storage[$name] = trim($value); |
|
53 | 53 | } else { |
54 | - $this->storage[ $name ] = $value; |
|
54 | + $this->storage[$name] = $value; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $this; |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | $classes = array_filter($classes); |
70 | 70 | |
71 | 71 | if ( ! $this->offsetExists('class')) { |
72 | - $this->storage[ 'class' ] = []; |
|
72 | + $this->storage['class'] = []; |
|
73 | 73 | } |
74 | 74 | |
75 | - $this->storage[ 'class' ] = array_merge($this->storage[ 'class' ], $classes); |
|
76 | - $this->storage[ 'class' ] = array_unique($this->storage[ 'class' ]); |
|
75 | + $this->storage['class'] = array_merge($this->storage['class'], $classes); |
|
76 | + $this->storage['class'] = array_unique($this->storage['class']); |
|
77 | 77 | |
78 | - if(in_array('disabled', $this->storage['class'])) { |
|
78 | + if (in_array('disabled', $this->storage['class'])) { |
|
79 | 79 | $this->removeAttributeClass('active'); |
80 | 80 | } |
81 | 81 | |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | if ( ! $this->offsetExists('style')) { |
94 | - $this->storage[ 'style' ] = []; |
|
94 | + $this->storage['style'] = []; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | foreach ($styles as $key => $value) { |
98 | 98 | if (empty($value)) { |
99 | 99 | continue; |
100 | 100 | } |
101 | - $styles[ trim($key) ] = trim($value); |
|
101 | + $styles[trim($key)] = trim($value); |
|
102 | 102 | } |
103 | 103 | |
104 | - $this->storage[ 'style' ] = array_merge($this->storage[ 'style' ], $styles); |
|
104 | + $this->storage['style'] = array_merge($this->storage['style'], $styles); |
|
105 | 105 | |
106 | 106 | return $this; |
107 | 107 | } |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | public function hasAttribute($name) |
112 | 112 | { |
113 | 113 | if ($name === 'id') { |
114 | - return empty($this->storage[ 'id' ]) ? false : true; |
|
114 | + return empty($this->storage['id']) ? false : true; |
|
115 | 115 | } elseif ($name === 'class') { |
116 | - return empty($this->storage[ 'class' ]) ? false : true; |
|
116 | + return empty($this->storage['class']) ? false : true; |
|
117 | 117 | } else { |
118 | - return isset($this->storage[ $name ]); |
|
118 | + return isset($this->storage[$name]); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | { |
126 | 126 | if (empty($name)) { |
127 | 127 | return $this->storage; |
128 | - } elseif (isset($this->storage[ $name ])) { |
|
129 | - return $this->storage[ $name ]; |
|
128 | + } elseif (isset($this->storage[$name])) { |
|
129 | + return $this->storage[$name]; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return false; |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | |
144 | 144 | foreach ($attributes as $attribute) { |
145 | 145 | if (array_key_exists($attribute, $this->storage)) { |
146 | - unset($this->storage[ $attribute ]); |
|
146 | + unset($this->storage[$attribute]); |
|
147 | 147 | } elseif (strpos($attribute, '*') !== false) { |
148 | 148 | $attribute = str_replace('*', '', $attribute); |
149 | 149 | foreach ($this->storage as $key => $value) { |
150 | 150 | if (preg_match("/\b$attribute\b/i", $key)) { |
151 | - unset($this->storage[ $key ]); |
|
151 | + unset($this->storage[$key]); |
|
152 | 152 | } |
153 | 153 | } |
154 | 154 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public function getAttributeId() |
161 | 161 | { |
162 | 162 | if ($this->hasAttributeId()) { |
163 | - return $this->storage[ 'id' ]; |
|
163 | + return $this->storage['id']; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | return false; |
@@ -170,25 +170,25 @@ discard block |
||
170 | 170 | |
171 | 171 | public function hasAttributeId() |
172 | 172 | { |
173 | - return (bool)empty($this->storage[ 'id' ]) ? false : true; |
|
173 | + return (bool)empty($this->storage['id']) ? false : true; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | public function hasAttributeClass($className) |
177 | 177 | { |
178 | 178 | if ( ! $this->offsetExists('class')) { |
179 | - $this->storage[ 'class' ] = []; |
|
179 | + $this->storage['class'] = []; |
|
180 | 180 | } |
181 | 181 | |
182 | - return in_array($className, $this->storage[ 'class' ]); |
|
182 | + return in_array($className, $this->storage['class']); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | public function getAttributeClass() |
186 | 186 | { |
187 | 187 | if ( ! $this->offsetExists('class')) { |
188 | - $this->storage[ 'class' ] = []; |
|
188 | + $this->storage['class'] = []; |
|
189 | 189 | } |
190 | 190 | |
191 | - return implode(', ', $this->storage[ 'class' ]); |
|
191 | + return implode(', ', $this->storage['class']); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | public function removeAttributeClass($classes) |
@@ -202,20 +202,20 @@ discard block |
||
202 | 202 | $classes = array_filter($classes); |
203 | 203 | |
204 | 204 | foreach ($classes as $class) { |
205 | - if (false !== ($key = array_search($class, $this->storage[ 'class' ]))) { |
|
206 | - unset($this->storage[ 'class' ][ $key ]); |
|
205 | + if (false !== ($key = array_search($class, $this->storage['class']))) { |
|
206 | + unset($this->storage['class'][$key]); |
|
207 | 207 | } elseif (strpos($class, '*') !== false) { |
208 | 208 | $class = str_replace('*', '', $class); |
209 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
209 | + foreach ($this->storage['class'] as $key => $value) { |
|
210 | 210 | if (preg_match("/\b$class\b/i", $value)) { |
211 | - unset($this->storage[ 'class' ][ $key ]); |
|
211 | + unset($this->storage['class'][$key]); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - if (count($this->storage[ 'class' ]) == 0) { |
|
218 | - unset($this->storage[ 'class' ]); |
|
217 | + if (count($this->storage['class']) == 0) { |
|
218 | + unset($this->storage['class']); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | } |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | public function replaceAttributeClass($class, $replace) |
224 | 224 | { |
225 | 225 | if ($this->offsetExists('class')) { |
226 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
226 | + foreach ($this->storage['class'] as $key => $value) { |
|
227 | 227 | if (preg_match("/\b$class\b/i", $value)) { |
228 | - $this->storage[ 'class' ][ $key ] = str_replace($class, $replace, $value); |
|
228 | + $this->storage['class'][$key] = str_replace($class, $replace, $value); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | - if (count($this->storage[ 'class' ]) == 0) { |
|
233 | - unset($this->storage[ 'class' ]); |
|
232 | + if (count($this->storage['class']) == 0) { |
|
233 | + unset($this->storage['class']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | if ($this->offsetExists('class')) { |
241 | 241 | $matches = []; |
242 | 242 | |
243 | - foreach ($this->storage[ 'class' ] as $key => $value) { |
|
243 | + foreach ($this->storage['class'] as $key => $value) { |
|
244 | 244 | if (preg_match("/\b$class\b/i", $value)) { |
245 | 245 | $matches[] = $value; |
246 | 246 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if (strpos($className, 'O2System\Html\\') === false) { |
21 | 21 | return; |
22 | 22 | } |