From c37a06b8f139aae50776235521b872df284ddbf9 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 20 Dec 2023 22:13:15 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20the=20Document=20class?= =?UTF-8?q?=20docblocks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Document.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Document.php b/src/Document.php index 9e3817e..7e79d19 100644 --- a/src/Document.php +++ b/src/Document.php @@ -21,9 +21,7 @@ class Document protected string $encoding = ''; /** - * Create a new DOM instance. - * - * @return void + * Initialize the Document instance. */ public function __construct(string $html) { @@ -40,7 +38,7 @@ public function __construct(string $html) } /** - * Make a new DOM instance. + * Make a new instance of the Document. */ public static function make(string $html): self { @@ -48,11 +46,9 @@ public static function make(string $html): self } /** - * Executes callback on each DOMElement. - * - * @param callable $callback + * Loop through each node in the document and execute the provided callback. */ - public function each($callback): self + public function each(callable $callback): self { foreach ($this->xpath('//*') as $node) { $callback($node); @@ -62,7 +58,7 @@ public function each($callback): self } /** - * Evaluates the given XPath expression. + * Evaluate the given XPath expression. */ public function xpath(string $expression): DOMNodeList { @@ -78,7 +74,7 @@ public function html(): string } /** - * Call methods on the root document. + * Call the given method on the root document. */ public function __call(string $name, array $arguments): mixed { @@ -86,7 +82,7 @@ public function __call(string $name, array $arguments): mixed } /** - * Get properties from the root document. + * Get the given property from the root document. */ public function __get(string $name): mixed {