Completed
Branch master (941dea)
by Thomas
03:15
created
Category
src/HtmlQuery.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function outerHtml()
47 47
     {
48
-        return $this->mapFirst(function (DOMNode $node) {
48
+        return $this->mapFirst(function(DOMNode $node) {
49 49
             return $this->doc->saveHTML($node);
50 50
         });
51 51
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getHtml()
76 76
     {
77
-        return $this->mapFirst(function (DOMNode $node) {
77
+        return $this->mapFirst(function(DOMNode $node) {
78 78
             $content = '';
79 79
             foreach (iterator_to_array($node->childNodes) as $childNode) {
80 80
                 $content .= $this->doc->saveHTML($childNode);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
      */
128 128
     public function getText()
129 129
     {
130
-        return $this->mapFirst(function (DOMNode $node) {
130
+        return $this->mapFirst(function(DOMNode $node) {
131 131
             return $node->textContent;
132 132
         });
133 133
     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function setText(string $text)
143 143
     {
144
-        return $this->each(function (DOMNode $node) use ($text) {
144
+        return $this->each(function(DOMNode $node) use ($text) {
145 145
             return $node->nodeValue = $text;
146 146
         });
147 147
     }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      */
182 182
     public function getAttr(string $name)
183 183
     {
184
-        return $this->mapFirst(function (DOMNode $node) use ($name) {
184
+        return $this->mapFirst(function(DOMNode $node) use ($name) {
185 185
             if (!($node instanceof DOMElement)) {
186 186
                 return null;
187 187
             }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function setAttr(string $name, string $value)
202 202
     {
203
-        return $this->each(function (DOMNode $node) use ($name, $value) {
203
+        return $this->each(function(DOMNode $node) use ($name, $value) {
204 204
             if ($node instanceof DOMElement) {
205 205
                 $node->setAttribute($name, $value);
206 206
             }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
      */
217 217
     public function removeAttr(string $attributeName)
218 218
     {
219
-        return $this->each(function (DOMNode $node) use ($attributeName) {
219
+        return $this->each(function(DOMNode $node) use ($attributeName) {
220 220
             if ($node instanceof DOMElement) {
221 221
                 $node->removeAttribute($attributeName);
222 222
             }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function removeAllAttrs($except = [])
234 234
     {
235
-        return $this->each(function (DOMNode $node) use ($except) {
235
+        return $this->each(function(DOMNode $node) use ($except) {
236 236
             $names = [];
237 237
             foreach (iterator_to_array($node->attributes) as $attribute) {
238 238
                 $names[] = $attribute->name;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
     public function hasAttr(string $attributeName)
257 257
     {
258 258
         return $this->mapAnyTrue(
259
-            function (DOMNode $node) use ($attributeName) {
259
+            function(DOMNode $node) use ($attributeName) {
260 260
                 if (!($node instanceof DOMElement)) {
261 261
                     return false;
262 262
                 }
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
     {
308 308
         if (is_array($name)) {
309 309
             $keys = array_keys($name);
310
-            $keys = array_map(function ($value) {
310
+            $keys = array_map(function($value) {
311 311
                 return 'data-' . $value;
312 312
             }, $keys);
313 313
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
      */
365 365
     public function empty()
366 366
     {
367
-        return $this->each(function (DOMNode $node) {
367
+        return $this->each(function(DOMNode $node) {
368 368
             $node->nodeValue = '';
369 369
         });
370 370
     }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         if (!is_null($selector)) {
383 383
             $this->filter($selector)->remove();
384 384
         } else {
385
-            $this->each(function (DOMNode $node) {
385
+            $this->each(function(DOMNode $node) {
386 386
                 if ($node->parentNode) {
387 387
                     $node->parentNode->removeChild($node);
388 388
                 }
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
      */
417 417
     public function getVal()
418 418
     {
419
-        return $this->mapFirst(function (DOMNode $node) {
419
+        return $this->mapFirst(function(DOMNode $node) {
420 420
             if (!($node instanceof DOMElement)) {
421 421
                 return null;
422 422
             }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
      */
455 455
     public function setVal(string $value)
456 456
     {
457
-        return $this->each(function (DOMNode $node) use ($value) {
457
+        return $this->each(function(DOMNode $node) use ($value) {
458 458
             if (!($node instanceof DOMElement)) {
459 459
                 return;
460 460
             }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
      */
493 493
     public function addClass(string $className)
494 494
     {
495
-        return $this->each(function (HtmlQuery $node) use ($className) {
495
+        return $this->each(function(HtmlQuery $node) use ($className) {
496 496
             if (!$node->hasAttr('class')) {
497 497
                 $node->setAttr('class', $className);
498 498
                 return;
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
     public function hasClass(string $className)
523 523
     {
524 524
         return $this->mapAnyTrue(
525
-            function (HtmlQuery $node) use ($className) {
525
+            function(HtmlQuery $node) use ($className) {
526 526
                 if (!$node->hasAttr('class')) {
527 527
                     return false;
528 528
                 }
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
      */
546 546
     public function removeClass(?string $className = null)
547 547
     {
548
-        return $this->each(function (HtmlQuery $node) use ($className) {
548
+        return $this->each(function(HtmlQuery $node) use ($className) {
549 549
             if (!$node->hasAttr('class')) {
550 550
                 return;
551 551
             }
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
      */
582 582
     public function toggleClass(?string $className, ?bool $state = null)
583 583
     {
584
-        return $this->each(function (HtmlQuery $node) use ($className, $state) {
584
+        return $this->each(function(HtmlQuery $node) use ($className, $state) {
585 585
             if (!is_null($state)) {
586 586
                 if ($state) {
587 587
                     $node->addClass($className);
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
      */
650 650
     public function getCss(string $name)
651 651
     {
652
-        return $this->mapFirst(function (HtmlQuery $node) use ($name) {
652
+        return $this->mapFirst(function(HtmlQuery $node) use ($name) {
653 653
             $style = (string) $node->attr('style');
654 654
             $css = Helper::splitCss($style);
655 655
             if (!$css) {
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
      */
681 681
     public function setCss(string $name, ?string $value)
682 682
     {
683
-        return $this->each(function (HtmlQuery $node) use ($name, $value) {
683
+        return $this->each(function(HtmlQuery $node) use ($name, $value) {
684 684
             if ((string) $value === '') {
685 685
                 $node->removeCss($name);
686 686
                 return;
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
      */
722 722
     public function removeCss(string $name)
723 723
     {
724
-        return $this->each(function (HtmlQuery $node) use ($name) {
724
+        return $this->each(function(HtmlQuery $node) use ($name) {
725 725
             $style = (string) $node->attr('style');
726 726
             if (!$style) {
727 727
                 return;
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
     {
765 765
         $content = $this->contentResolve($content);
766 766
 
767
-        return $this->each(function (DOMNode $node, $index) use ($content) {
768
-            $content->each(function (DOMNode $newNode) use ($node, $index) {
767
+        return $this->each(function(DOMNode $node, $index) use ($content) {
768
+            $content->each(function(DOMNode $newNode) use ($node, $index) {
769 769
                 if ($node->parentNode) {
770 770
                     $newNode = $index !== $this->count() - 1
771 771
                         ? $newNode->cloneNode(true)
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
     {
803 803
         $content = $this->contentResolve($content);
804 804
 
805
-        return $this->each(function (HtmlQuery $node, $index) use ($content) {
806
-            $content->each(function (DOMNode $newNode) use ($node, $index) {
805
+        return $this->each(function(HtmlQuery $node, $index) use ($content) {
806
+            $content->each(function(DOMNode $newNode) use ($node, $index) {
807 807
                 $newNode = $index !== $this->count() - 1
808 808
                     ? $newNode->cloneNode(true)
809 809
                     : $newNode;
@@ -842,8 +842,8 @@  discard block
 block discarded – undo
842 842
     {
843 843
         $content = $this->contentResolve($content);
844 844
 
845
-        return $this->each(function (DOMNode $node, $index) use ($content) {
846
-            $content->each(function (DOMNode $newNode) use ($node, $index) {
845
+        return $this->each(function(DOMNode $node, $index) use ($content) {
846
+            $content->each(function(DOMNode $newNode) use ($node, $index) {
847 847
                 $newNode = $index !== $this->count() - 1
848 848
                     ? $newNode->cloneNode(true)
849 849
                     : $newNode;
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
     {
879 879
         $content = $this->contentResolve($content);
880 880
 
881
-        return $this->each(function (DOMNode $node, $index) use ($content) {
882
-            $content->each(function (DOMNode $newNode) use ($node, $index) {
881
+        return $this->each(function(DOMNode $node, $index) use ($content) {
882
+            $content->each(function(DOMNode $newNode) use ($node, $index) {
883 883
                 $newNode = $index !== $this->count() - 1
884 884
                     ? $newNode->cloneNode(true)
885 885
                     : $newNode;
@@ -917,14 +917,14 @@  discard block
 block discarded – undo
917 917
     public function replaceWith($content)
918 918
     {
919 919
         $content = $this->contentResolve($content);
920
-        return $this->each(function (DOMNode $node, $index) use ($content) {
920
+        return $this->each(function(DOMNode $node, $index) use ($content) {
921 921
             if (!$node->parentNode) {
922 922
                 return;
923 923
             }
924 924
 
925 925
             $len = $content->count();
926 926
             $content->each(
927
-                function (DOMNode $newNode) use ($node, $index, $len) {
927
+                function(DOMNode $newNode) use ($node, $index, $len) {
928 928
                     $newNode = $index !== $this->count() - 1
929 929
                         ? $newNode->cloneNode(true)
930 930
                         : $newNode;
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 
975 975
         $newNode = $content[0];
976 976
 
977
-        return $this->each(function (DOMNode $node, $index) use ($newNode) {
977
+        return $this->each(function(DOMNode $node, $index) use ($newNode) {
978 978
             $newNode = $index !== $this->count() - 1
979 979
                 ? $newNode->cloneNode(true)
980 980
                 : $newNode;
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 
1007 1007
         $newNode = $content[0];
1008 1008
 
1009
-        return $this->each(function (DOMNode $node, $index) use ($newNode) {
1009
+        return $this->each(function(DOMNode $node, $index) use ($newNode) {
1010 1010
             $newNode = $index !== $this->count() - 1
1011 1011
                 ? $newNode->cloneNode(true)
1012 1012
                 : $newNode;
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
         }
1044 1044
 
1045 1045
         $newNode = $content[0];
1046
-        $this->each(function (DOMNode $node, $index) use ($newNode) {
1046
+        $this->each(function(DOMNode $node, $index) use ($newNode) {
1047 1047
             if ($index === 0) {
1048 1048
                 $this->resolve($node)->wrap($newNode);
1049 1049
             } else {
@@ -1075,7 +1075,7 @@  discard block
 block discarded – undo
1075 1075
      */
1076 1076
     public function unwrapSelf()
1077 1077
     {
1078
-        return $this->each(function (DOMNode $node) {
1078
+        return $this->each(function(DOMNode $node) {
1079 1079
             if (!$node->parentNode) {
1080 1080
                 return;
1081 1081
             }
Please login to merge, or discard this patch.
src/Helper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public static function strictArrayIntersect(array $arr1, array $arr2): array
60 60
     {
61
-        $arr = array_filter($arr1, function ($val1) use ($arr2) {
61
+        $arr = array_filter($arr1, function($val1) use ($arr2) {
62 62
             return in_array($val1, $arr2, true);
63 63
         });
64 64
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public static function strictArrayDiff(array $arr1, array $arr2): array
77 77
     {
78
-        $arr = array_filter($arr1, function ($val1) use ($arr2) {
78
+        $arr = array_filter($arr1, function($val1) use ($arr2) {
79 79
             return !in_array($val1, $arr2, true);
80 80
         });
81 81
 
Please login to merge, or discard this patch.