Passed
Push — master ( 0d4bed...8e4c14 )
by smiley
03:55
created
src/NodeList.php 3 patches
Unused Use Statements   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,10 @@
 block discarded – undo
16 16
 use chillerlan\PrototypeDOM\Node\{PrototypeNode};
17 17
 use chillerlan\Traits\{Enumerable, Interfaces\ArrayAccessTrait, Magic};
18 18
 use chillerlan\Traits\SPL\{CountableTrait, SeekableIteratorTrait};
19
-use Countable, DOMNode, DOMNodeList, SeekableIterator;
19
+use Countable;
20
+use DOMNode;
21
+use DOMNodeList;
22
+use SeekableIterator;
20 23
 
21 24
 use function array_column, array_merge, array_reverse, is_int, is_iterable, iterator_to_array;
22 25
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @throws \Exception
52 52
 	 */
53
-	public function __construct(iterable $nodes = null){
53
+	public function __construct(iterable $nodes = null) {
54 54
 
55
-		if($nodes instanceof DOMNodeList){
55
+		if ($nodes instanceof DOMNodeList) {
56 56
 			$this->array = iterator_to_array($nodes);
57 57
 		}
58
-		elseif($nodes instanceof NodeList){
58
+		elseif ($nodes instanceof NodeList) {
59 59
 			$this->array = $nodes->toArray();
60 60
 		}
61
-		elseif(is_iterable($nodes)){
62
-			foreach($nodes as $node){
63
-				if($node instanceof DOMNode || $node instanceof PrototypeNode){
61
+		elseif (is_iterable($nodes)) {
62
+			foreach ($nodes as $node) {
63
+				if ($node instanceof DOMNode || $node instanceof PrototypeNode) {
64 64
 					$this->array[] = $node;
65 65
 				}
66 66
 			}
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public function match(DOMNode $node):bool{
93 93
 		/** @var \chillerlan\PrototypeDOM\Node\Element $element */
94
-		foreach($this->array as $element){
94
+		foreach ($this->array as $element) {
95 95
 
96
-			if($element->isSameNode($node)){
96
+			if ($element->isSameNode($node)) {
97 97
 				return true;
98 98
 			}
99 99
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null
109 109
 	 */
110
-	public function item(int $offset):?DOMNode{
110
+	public function item(int $offset): ?DOMNode{
111 111
 		return $this->array[$offset] ?? null;
112 112
 	}
113 113
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	public function offsetSet($offset, $value):void{
145 145
 
146
-		if($value instanceof DOMNode){
146
+		if ($value instanceof DOMNode) {
147 147
 
148 148
 			is_int($offset)
149 149
 				? $this->array[$offset] = $value
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null
160 160
 	 */
161
-	public function first():?DOMNode{
161
+	public function first(): ?DOMNode{
162 162
 		return $this->__first();
163 163
 	}
164 164
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeNode|\DOMNode|null
169 169
 	 */
170
-	public function last():?DOMNode{
170
+	public function last(): ?DOMNode{
171 171
 		return $this->__last();
172 172
 	}
173 173
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,11 +54,9 @@
 block discarded – undo
54 54
 
55 55
 		if($nodes instanceof DOMNodeList){
56 56
 			$this->array = iterator_to_array($nodes);
57
-		}
58
-		elseif($nodes instanceof NodeList){
57
+		} elseif($nodes instanceof NodeList){
59 58
 			$this->array = $nodes->toArray();
60
-		}
61
-		elseif(is_iterable($nodes)){
59
+		} elseif(is_iterable($nodes)){
62 60
 			foreach($nodes as $node){
63 61
 				if($node instanceof DOMNode || $node instanceof PrototypeNode){
64 62
 					$this->array[] = $node;
Please login to merge, or discard this patch.
src/Document.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * @property string $title
29 29
  */
30
-class Document extends DOMDocument{
30
+class Document extends DOMDocument {
31 31
 	use Magic;
32 32
 
33 33
 	protected const NODE_CLASSES = [
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 	 * @param string|null                                                $version
62 62
 	 * @param string|null                                                $encoding
63 63
 	 */
64
-	public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null){
64
+	public function __construct($content = null, bool $xml = null, string $version = null, string $encoding = null) {
65 65
 		parent::__construct($version ?? '1.0', $encoding ?? 'UTF-8');
66 66
 
67
-		foreach($this::NODE_CLASSES as $baseClass => $extendedClass){
67
+		foreach ($this::NODE_CLASSES as $baseClass => $extendedClass) {
68 68
 			$this->registerNodeClass($baseClass, $extendedClass);
69 69
 		}
70 70
 
71
-		if($content !== null){
71
+		if ($content !== null) {
72 72
 			$this->loadDocument($content, $xml);
73 73
 		}
74 74
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * magic *
80 80
 	 *********/
81 81
 
82
-	public function magic_get_title():?string{
82
+	public function magic_get_title(): ?string{
83 83
 		return $this->select(['head > title'])->item(0)->nodeValue ?? null;
84 84
 	}
85 85
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	public function magic_set_title(string $title):void{
92 92
 		$currentTitle = $this->select(['head > title'])->item(0);
93 93
 
94
-		if($currentTitle instanceof Element){
94
+		if ($currentTitle instanceof Element) {
95 95
 			$currentTitle->update($title);
96 96
 
97 97
 			return;
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 		$head         = $this->select(['head'])->item(0);
101 101
 		$currentTitle = $this->newElement('title')->update($title);
102 102
 
103
-		if(!$head){
103
+		if (!$head) {
104 104
 			$html = $this->select(['html'])->first();
105 105
 
106
-			if(!$html instanceof PrototypeHTMLElement){
106
+			if (!$html instanceof PrototypeHTMLElement) {
107 107
 				throw new DOMException('<html> header missing');
108 108
 			}
109 109
 
@@ -124,19 +124,19 @@  discard block
 block discarded – undo
124 124
 
125 125
 	public function loadDocument($content, bool $xml = null):Document{
126 126
 
127
-		if($content instanceof NodeList){
127
+		if ($content instanceof NodeList) {
128 128
 			return $this->insertNodeList($content);
129 129
 		}
130 130
 
131
-		if($content instanceof DOMNodeList){
131
+		if ($content instanceof DOMNodeList) {
132 132
 			return $this->insertNodeList(new NodeList($content));
133 133
 		}
134 134
 
135
-		if(!is_string($content)){
135
+		if (!is_string($content)) {
136 136
 			throw new DOMException('invalid document content');
137 137
 		}
138 138
 
139
-		if(is_file($content) && is_readable($content)){
139
+		if (is_file($content) && is_readable($content)) {
140 140
 			return $this->loadDocumentFile($content, $xml);
141 141
 		}
142 142
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			? $this->load($file, $options)
159 159
 			: $this->loadHTMLFile($file, $options);
160 160
 
161
-		if($result === false){
161
+		if ($result === false) {
162 162
 			throw new DOMException('failed to load document from file: '.$file); // @codeCoverageIgnore
163 163
 		}
164 164
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 			? $this->loadXML($documentSource, $options)
181 181
 			: $this->loadHTML($documentSource, $options);
182 182
 
183
-		if($result === false){
183
+		if ($result === false) {
184 184
 			throw new DOMException('failed to load document from string'); // @codeCoverageIgnore
185 185
 		}
186 186
 
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function toNodeList($content):NodeList{
197 197
 
198
-		if($content instanceof NodeList){
198
+		if ($content instanceof NodeList) {
199 199
 			return $content;
200 200
 		}
201 201
 
202
-		if($content instanceof DOMNode || $content instanceof PrototypeNode){
202
+		if ($content instanceof DOMNode || $content instanceof PrototypeNode) {
203 203
 			return new NodeList([$content]);
204 204
 		}
205 205
 
206
-		if($content instanceof DOMNodeList || is_iterable($content)){
206
+		if ($content instanceof DOMNodeList || is_iterable($content)) {
207 207
 			return new NodeList($content);
208 208
 		}
209 209
 
210
-		if(is_string($content)){
210
+		if (is_string($content)) {
211 211
 			$document = new self;
212 212
 			$document->loadHTML('<html><body id="-import-content">'.$content.'</body></html>');
213 213
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return \chillerlan\PrototypeDOM\NodeList|null
239 239
 	 */
240
-	public function query(string $xpath, DOMNode $contextNode = null):?NodeList{
240
+	public function query(string $xpath, DOMNode $contextNode = null): ?NodeList{
241 241
 		$q = (new DOMXPath($this))->query($xpath, $contextNode);
242 242
 
243 243
 		return $q !== false ? new NodeList($q) : null;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return \chillerlan\PrototypeDOM\NodeList|null
252 252
 	 */
253
-	public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null):?NodeList{
253
+	public function querySelectorAll(string $selector, DOMNode $contextNode = null, string $axis = null): ?NodeList{
254 254
 		return $this->query($this->cssSelectorConverter->toXPath($selector, $axis ?? 'descendant-or-self::'), $contextNode);
255 255
 	}
256 256
 
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 		/** @var \chillerlan\PrototypeDOM\NodeList $nodes */
266 266
 		$nodes = $this->select($selectors, $contextNode, $axis ?? 'descendant-or-self::');
267 267
 
268
-		if(count($nodes) > 0){
268
+		if (count($nodes) > 0) {
269 269
 
270
-			foreach($nodes as $node){
270
+			foreach ($nodes as $node) {
271 271
 				$node->remove();
272 272
 			}
273 273
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	public function insertNodeList(NodeList $nodeList):Document{
285 285
 
286 286
 		/** @var \DOMNode $node */
287
-		foreach($nodeList as $node){
287
+		foreach ($nodeList as $node) {
288 288
 			$this->appendChild($this->importNode($node->cloneNode(true), true));
289 289
 		}
290 290
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	public function inspect(DOMNode $context = null, bool $xml = null):string{
307 307
 
308
-		if($xml === true){
308
+		if ($xml === true) {
309 309
 			return $this->saveXML($context);
310 310
 		}
311 311
 
@@ -326,15 +326,15 @@  discard block
 block discarded – undo
326 326
 		$nodeType = $nodeType ?? XML_ELEMENT_NODE;
327 327
 		$elements = new NodeList;
328 328
 
329
-		foreach($selectors ?? ['*'] as $selector){
329
+		foreach ($selectors ?? ['*'] as $selector) {
330 330
 
331
-			if(!is_string($selector)){
331
+			if (!is_string($selector)) {
332 332
 				continue;
333 333
 			}
334 334
 
335
-			foreach($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element){
335
+			foreach ($this->querySelectorAll($selector, $contextNode, $axis ?? 'descendant-or-self::') as $element) {
336 336
 
337
-				if($element->nodeType === $nodeType){
337
+				if ($element->nodeType === $nodeType) {
338 338
 					$elements[] = $element;
339 339
 				}
340 340
 
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
 		$maxLength = $maxLength ?? -1;
361 361
 		$nodes     = new NodeList;
362 362
 
363
-		if(in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){
363
+		if (in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) {
364 364
 
365
-			while($element = $element->{$property}){
365
+			while ($element = $element->{$property}) {
366 366
 
367
-				if($element->nodeType === $nodeType){
367
+				if ($element->nodeType === $nodeType) {
368 368
 					$nodes[] = $element;
369 369
 				}
370 370
 
371
-				if(count($nodes) === $maxLength){
371
+				if (count($nodes) === $maxLength) {
372 372
 					break;
373 373
 				}
374 374
 
@@ -388,16 +388,16 @@  discard block
 block discarded – undo
388 388
 	 *
389 389
 	 * @return \DOMNode|null
390 390
 	 */
391
-	public function recursivelyFind(DOMNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null):?DOMNode{
391
+	public function recursivelyFind(DOMNode $element, string $property = null, string $selector = null, int $index = null, int $nodeType = null): ?DOMNode{
392 392
 		$nodeType = $nodeType ?? XML_ELEMENT_NODE;
393 393
 		$index    = $index ?? 0;
394 394
 
395
-		if(in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])){
395
+		if (in_array($property, ['parentNode', 'previousSibling', 'nextSibling'])) {
396 396
 
397 397
 			/** @var \chillerlan\PrototypeDOM\Node\Element $element */
398
-			while($element = $element->{$property}){
398
+			while ($element = $element->{$property}) {
399 399
 
400
-				if($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0){
400
+				if ($element->nodeType !== $nodeType || $selector !== null && !$element->match($selector) || --$index >= 0) {
401 401
 					continue;
402 402
 				}
403 403
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	public function match(DOMNode $element, string $selector):bool{
421 421
 
422 422
 		/** @var \chillerlan\PrototypeDOM\Node\Element $match */
423
-		foreach($this->select([$selector]) as $match){
423
+		foreach ($this->select([$selector]) as $match) {
424 424
 
425
-			if($element->isSameNode($match)){
425
+			if ($element->isSameNode($match)) {
426 426
 				return true;
427 427
 			}
428 428
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 		/** @var \chillerlan\PrototypeDOM\Node\Element $element */
444 444
 		$element = $this->createElement($tag);
445 445
 
446
-		if($attributes !== null){
446
+		if ($attributes !== null) {
447 447
 			$element->setAttributes($attributes);
448 448
 		}
449 449
 
@@ -456,9 +456,9 @@  discard block
 block discarded – undo
456 456
 	 * @return \DOMNode|null
457 457
 	 * @throws \DOMException
458 458
 	 */
459
-	public function getElementById($elementId):?DOMNode{
459
+	public function getElementById($elementId): ?DOMNode{
460 460
 
461
-		if(!is_string($elementId)){
461
+		if (!is_string($elementId)) {
462 462
 			throw new DOMException('invalid element id');
463 463
 		}
464 464
 
Please login to merge, or discard this patch.
src/Node/PrototypeTraversalTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 /**
23 23
  * @property \chillerlan\PrototypeDOM\Document $ownerDocument
24 24
  */
25
-trait PrototypeTraversalTrait{
25
+trait PrototypeTraversalTrait {
26 26
 
27 27
 	use PrototypeNodeTrait;
28 28
 
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|\DOMNode|null
36 36
 	 */
37
-	public function recursivelyFind($selector, int $index = null, string $property = null, int $nodeType = XML_ELEMENT_NODE):?PrototypeTraversal{
37
+	public function recursivelyFind($selector, int $index = null, string $property = null, int $nodeType = XML_ELEMENT_NODE): ?PrototypeTraversal{
38 38
 
39
-		if(is_numeric($selector)){
39
+		if (is_numeric($selector)) {
40 40
 			return $this->ownerDocument->recursivelyFind($this, $property, null, $selector, $nodeType);
41 41
 		}
42 42
 
@@ -73,19 +73,19 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
75 75
 	 */
76
-	public function down($expression = null, int $index = null):?PrototypeTraversal{
76
+	public function down($expression = null, int $index = null): ?PrototypeTraversal{
77 77
 
78
-		if($expression === null && $index === null){
78
+		if ($expression === null && $index === null) {
79 79
 			return $this->firstDescendant();
80 80
 		}
81 81
 
82 82
 		$index = $index ?? 0;
83 83
 
84
-		if(is_int($expression)){
84
+		if (is_int($expression)) {
85 85
 			return $this->select(['*'])->item($expression);
86 86
 		}
87 87
 
88
-		if(is_array($expression)){
88
+		if (is_array($expression)) {
89 89
 			return $this->select($expression)->item($index);
90 90
 		}
91 91
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
102 102
 	 */
103
-	public function up($expression = null, int $index = null):?PrototypeTraversal{
103
+	public function up($expression = null, int $index = null): ?PrototypeTraversal{
104 104
 		return $this->recursivelyFind($expression, $index, 'parentNode');
105 105
 	}
106 106
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
114 114
 	 */
115
-	public function previous($expression = null, int $index = null):?PrototypeTraversal{
115
+	public function previous($expression = null, int $index = null): ?PrototypeTraversal{
116 116
 		return $this->recursivelyFind($expression, $index, 'previousSibling');
117 117
 	}
118 118
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
126 126
 	 */
127
-	public function next($expression = null, int $index = null):?PrototypeTraversal{
127
+	public function next($expression = null, int $index = null): ?PrototypeTraversal{
128 128
 		return $this->recursivelyFind($expression, $index, 'nextSibling');
129 129
 	}
130 130
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 		$nodeType = $nodeType ?? XML_ELEMENT_NODE;
140 140
 		$children = new NodeList;
141 141
 
142
-		if(!$this->hasChildNodes()){
142
+		if (!$this->hasChildNodes()) {
143 143
 			return $children;
144 144
 		}
145 145
 
146
-		foreach($this->childNodes as $child){
146
+		foreach ($this->childNodes as $child) {
147 147
 
148
-			if($child->nodeType === $nodeType){
148
+			if ($child->nodeType === $nodeType) {
149 149
 				$children[] = $child;
150 150
 			}
151 151
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 *
198 198
 	 * @return \chillerlan\PrototypeDOM\Node\PrototypeTraversal|null
199 199
 	 */
200
-	public function firstDescendant():?PrototypeTraversal{
200
+	public function firstDescendant(): ?PrototypeTraversal{
201 201
 		return $this->descendants()->first();
202 202
 	}
203 203
 
Please login to merge, or discard this patch.
src/Node/PrototypeHTMLElementTrait.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
  * @property string $src
24 24
  * @property string $innerHTML
25 25
  */
26
-trait PrototypeHTMLElementTrait{
26
+trait PrototypeHTMLElementTrait {
27 27
 	use Magic, PrototypeElementTrait;
28 28
 
29 29
 	protected function magic_get_id():string{
30 30
 		return trim($this->getAttribute('id'));
31 31
 	}
32 32
 
33
-	protected function magic_set_id(string $id){
33
+	protected function magic_set_id(string $id) {
34 34
 		return $this->setAttribute('id', $id);
35 35
 	}
36 36
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		return trim($this->getAttribute('class'));
39 39
 	}
40 40
 
41
-	protected function magic_set_class(string $class){
41
+	protected function magic_set_class(string $class) {
42 42
 		return $this->setAttribute('class', $class);
43 43
 	}
44 44
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		return trim($this->getAttribute('href'));
47 47
 	}
48 48
 
49
-	protected function magic_set_href(string $href){
49
+	protected function magic_set_href(string $href) {
50 50
 		return $this->setAttribute('href', $href);
51 51
 	}
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		return trim($this->getAttribute('src'));
55 55
 	}
56 56
 
57
-	protected function magic_set_src(string $src){
57
+	protected function magic_set_src(string $src) {
58 58
 		return $this->setAttribute('src', $src);
59 59
 	}
60 60
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	public function identify(string $newID = null):string{
73 73
 		$oldID = $this->id;
74 74
 
75
-		if($newID !== null){
75
+		if ($newID !== null) {
76 76
 			$this->id = $newID;
77 77
 		}
78 78
 
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function classNames():array{
88 88
 
89
-		if(!$this->hasAttributes()){
89
+		if (!$this->hasAttributes()) {
90 90
 			return [];
91 91
 		}
92 92
 
93 93
 		$classnames        = explode(' ', $this->class);
94 94
 		$currentClassnames = [];
95 95
 
96
-		foreach($classnames as $classname){
96
+		foreach ($classnames as $classname) {
97 97
 			$classname = trim($classname);
98 98
 
99
-			if(!empty($classname)){
99
+			if (!empty($classname)) {
100 100
 				$currentClassnames[] = $classname;
101 101
 			}
102 102
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function toggleClassName(string $classname):PrototypeHTMLElement{
149 149
 
150
-		if($this->hasClassName($classname)){
150
+		if ($this->hasClassName($classname)) {
151 151
 			return $this->removeClassName($classname);
152 152
 		}
153 153
 
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return null|string
163 163
 	 */
164
-	public function getStyle(string $property):?string{
164
+	public function getStyle(string $property): ?string{
165 165
 		$currentStyle = $this->getStyles();
166 166
 
167
-		if(array_key_exists(strtolower($property), $currentStyle)){
167
+		if (array_key_exists(strtolower($property), $currentStyle)) {
168 168
 			return $currentStyle[$property];
169 169
 		}
170 170
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	public function setStyle(array $style, bool $replace = null):PrototypeHTMLElement{
183 183
 		$currentStyle = $this->getStyles();
184 184
 
185
-		if($replace !== true){
185
+		if ($replace !== true) {
186 186
 			$style = array_merge($currentStyle, $style);
187 187
 		}
188 188
 
189
-		foreach($style as $property => $value){
189
+		foreach ($style as $property => $value) {
190 190
 			$style[$property] = $property.': '.$value.';';
191 191
 		}
192 192
 
Please login to merge, or discard this patch.
src/Node/PrototypeElementTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 use function array_key_exists, call_user_func_array, is_array;
16 16
 
17
-trait PrototypeElementTrait{
17
+trait PrototypeElementTrait {
18 18
 
19 19
 	use PrototypeTraversalTrait;
20 20
 
@@ -55,28 +55,28 @@  discard block
 block discarded – undo
55 55
 	 */
56 56
 	public function insert($content):PrototypeElement{
57 57
 
58
-		if(!is_array($content)){
58
+		if (!is_array($content)) {
59 59
 
60
-			foreach($this->ownerDocument->toNodeList($content) as $node){
60
+			foreach ($this->ownerDocument->toNodeList($content) as $node) {
61 61
 				$this->insert_bottom($node);
62 62
 			}
63 63
 
64 64
 			return $this;
65 65
 		}
66 66
 
67
-		foreach(['before', 'after', 'top', 'bottom'] as $pos){
67
+		foreach (['before', 'after', 'top', 'bottom'] as $pos) {
68 68
 
69
-			if(!array_key_exists($pos, $content)){
69
+			if (!array_key_exists($pos, $content)) {
70 70
 				continue;
71 71
 			}
72 72
 
73 73
 			$nodes = $this->ownerDocument->toNodeList($content[$pos]);
74 74
 
75
-			if($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling){
75
+			if ($pos === 'top' && $this->hasChildNodes() || $pos === 'after' && $this->nextSibling) {
76 76
 				$nodes->reverse();
77 77
 			}
78 78
 
79
-			foreach($nodes as $node){
79
+			foreach ($nodes as $node) {
80 80
 				call_user_func_array([$this, 'insert_'.$pos], [$node]);
81 81
 			}
82 82
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function insert_before(PrototypeElement $node, PrototypeElement $refNode = null):PrototypeElement{
95 95
 
96
-		if($this->parentNode){
96
+		if ($this->parentNode) {
97 97
 			$this->parentNode->insertBefore($this->importNode($node), $refNode ?? $this);
98 98
 		}
99 99
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function insert_after(PrototypeElement $node):PrototypeElement{
109 109
 
110
-		if(!$this->nextSibling && $this->parentNode){
110
+		if (!$this->nextSibling && $this->parentNode) {
111 111
 			return $this->parentNode->insert_bottom($node); // @codeCoverageIgnore
112 112
 		}
113 113
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public function insert_top(PrototypeElement $node):PrototypeElement{
123 123
 
124
-		if($this->hasChildNodes()){
124
+		if ($this->hasChildNodes()) {
125 125
 			return $this->firstChild->insert_before($node, $this->firstChild);
126 126
 		}
127 127
 
Please login to merge, or discard this patch.
src/Node/Element.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 use function array_keys, array_unique, count, explode, implode, in_array, strtolower, trim;
18 18
 
19
-class Element extends DOMElement implements PrototypeHTMLElement{
19
+class Element extends DOMElement implements PrototypeHTMLElement {
20 20
 
21 21
 	use PrototypeHTMLElementTrait;
22 22
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	public function getAttributes():array{
27 27
 		$attributes = [];
28 28
 
29
-		foreach($this->attributes as $attribute){
29
+		foreach ($this->attributes as $attribute) {
30 30
 			$attributes[$attribute->nodeName] = $attribute->nodeValue;
31 31
 		}
32 32
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function setAttributes(array $attributes):PrototypeHTMLElement{
42 42
 
43
-		foreach($attributes as $name => $value){
43
+		foreach ($attributes as $name => $value) {
44 44
 			$this->setAttribute($name, $value);
45 45
 		}
46 46
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function removeAttributes(array $attributes):PrototypeHTMLElement{
56 56
 
57
-		foreach($attributes as $name){
57
+		foreach ($attributes as $name) {
58 58
 			$this->removeAttribute($name);
59 59
 		}
60 60
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	public function addClassNames(array $classnames):PrototypeHTMLElement{
70 70
 		$currentClassnames = $this->classNames();
71 71
 
72
-		foreach($classnames as $classname){
72
+		foreach ($classnames as $classname) {
73 73
 
74
-			if(!in_array($classname, $currentClassnames, true)){
74
+			if (!in_array($classname, $currentClassnames, true)) {
75 75
 				$currentClassnames[] = $classname;
76 76
 			}
77 77
 
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	public function removeClassNames(array $classnames):PrototypeHTMLElement{
91 91
 		$currentClassnames = $this->classNames();
92 92
 
93
-		foreach($classnames as $classname){
93
+		foreach ($classnames as $classname) {
94 94
 			$keys = array_keys($currentClassnames, $classname);
95 95
 
96
-			foreach($keys as $key){
96
+			foreach ($keys as $key) {
97 97
 				unset($currentClassnames[$key]);
98 98
 			}
99 99
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function getStyles():array{
111 111
 
112
-		if(!$this->hasAttributes()){
112
+		if (!$this->hasAttributes()) {
113 113
 			return [];
114 114
 		}
115 115
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 
118 118
 		$currentStyle = [];
119 119
 
120
-		foreach($styles as $style){
120
+		foreach ($styles as $style) {
121 121
 			$s = explode(':', $style);
122 122
 
123
-			if(count($s) === 2){
123
+			if (count($s) === 2) {
124 124
 				$currentStyle[strtolower(trim($s[0]))] = trim($s[1]);
125 125
 			}
126 126
 
Please login to merge, or discard this patch.
src/Node/PrototypeNodeTrait.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  * @property string                                $baseURI
37 37
  * @property string                                $textContent
38 38
  */
39
-trait PrototypeNodeTrait{
39
+trait PrototypeNodeTrait {
40 40
 
41 41
 	/**
42 42
 	 * @link http://api.prototypejs.org/dom/Element/recursivelyCollect/
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function remove():PrototypeNode{
80 80
 
81
-		if(!$this->parentNode){
81
+		if (!$this->parentNode) {
82 82
 			return $this;
83 83
 		}
84 84
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function replace(PrototypeNode $newnode):PrototypeNode{
96 96
 
97
-		if(!$this->parentNode){
97
+		if (!$this->parentNode) {
98 98
 			return $this;
99 99
 		}
100 100
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function purge():PrototypeNode{
108 108
 
109
-		while($this->hasChildNodes()){
109
+		while ($this->hasChildNodes()) {
110 110
 			$this->firstChild->remove();
111 111
 		}
112 112
 
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	public function cleanWhitespace():PrototypeNode{
122 122
 		$node = $this->firstChild;
123 123
 
124
-		while($node){
124
+		while ($node) {
125 125
 			$nextNode = $node->nextSibling;
126 126
 
127
-			if($node->nodeType === XML_TEXT_NODE && $node->empty()){
127
+			if ($node->nodeType === XML_TEXT_NODE && $node->empty()) {
128 128
 				$node->remove();
129 129
 			}
130 130
 
Please login to merge, or discard this patch.