Skip to content

Commit 5bbd75b

Browse files
Use DOMNodeList with array syntax
This is not only more readable, but also a bit faster [1] (though I doubt this code is a bottleneck anywhere either way). [1]: https://3v4l.org/NGEKe
1 parent e9a784a commit 5bbd75b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/HtmlParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getRootNode( DOMDocument $document ): DOMElement {
5959
throw new Exception( 'Template should have only one root node' );
6060
}
6161

62-
return $rootNodes->item( 0 );
62+
return $rootNodes[0];
6363
}
6464

6565
/**
@@ -81,7 +81,7 @@ public function getHtmlElement( DOMDocument $document ): DOMElement {
8181
*/
8282
public function getBodyElement( DOMDocument $document ): DOMElement {
8383
$htmlElement = $this->getHtmlElement( $document );
84-
$bodyElement = $htmlElement->childNodes->item( 0 );
84+
$bodyElement = $htmlElement->childNodes[0];
8585
if ( $bodyElement->tagName !== 'body' ) {
8686
throw new Exception( "Expected <body>, got <{$bodyElement->tagName}>" );
8787
}

0 commit comments

Comments
 (0)