Skip to content

Commit

Permalink
🎨 Improve the Document class docblocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Dec 21, 2023
1 parent f8d24be commit c37a06b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class Document
protected string $encoding = '<?xml encoding="UTF-8">';

/**
* Create a new DOM instance.
*
* @return void
* Initialize the Document instance.
*/
public function __construct(string $html)
{
Expand All @@ -40,19 +38,17 @@ public function __construct(string $html)
}

/**
* Make a new DOM instance.
* Make a new instance of the Document.
*/
public static function make(string $html): self
{
return new static($html);
}

/**
* 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);
Expand All @@ -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
{
Expand All @@ -78,15 +74,15 @@ 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
{
return $this->document->{$name}(...$arguments);
}

/**
* Get properties from the root document.
* Get the given property from the root document.
*/
public function __get(string $name): mixed
{
Expand Down

0 comments on commit c37a06b

Please sign in to comment.