@@ -45,7 +45,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | |
| 977 | 977 | $newNode = $content[0]; |
| 978 | 978 | |
| 979 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 979 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 980 | 980 | $newNode = $index !== $this->count() - 1 |
| 981 | 981 | ? $newNode->cloneNode(true) |
| 982 | 982 | : $newNode; |
@@ -1008,7 +1008,7 @@ discard block |
||
| 1008 | 1008 | return $this; |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | - return $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 1011 | + return $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 1012 | 1012 | $newNode = $index !== $this->count() - 1 |
| 1013 | 1013 | ? $newNode->cloneNode(true) |
| 1014 | 1014 | : $newNode; |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | $newNode = $content[0]; |
| 1048 | - $this->each(function (DOMNode $node, $index) use ($newNode) { |
|
| 1048 | + $this->each(function(DOMNode $node, $index) use ($newNode) { |
|
| 1049 | 1049 | if ($index === 0) { |
| 1050 | 1050 | $this->resolve($node)->wrap($newNode); |
| 1051 | 1051 | } else { |
@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | */ |
| 1078 | 1078 | public function unwrapSelf() |
| 1079 | 1079 | { |
| 1080 | - return $this->each(function (DOMNode $node) { |
|
| 1080 | + return $this->each(function(DOMNode $node) { |
|
| 1081 | 1081 | if (!$node->parentNode) { |
| 1082 | 1082 | return; |
| 1083 | 1083 | } |