Skip to content

Commit

Permalink
prevent calling ->end() on root node
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Jul 30, 2024
1 parent 2e52bd5 commit f8231f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ public function child(?string $label = null): self
return $child;
}

public function end(): ?self
public function end(): self
{
if ($this->parent === null) {
throw new \LogicException('Cannot call end() on root node');
}

return $this->parent;
}

Expand Down

0 comments on commit f8231f1

Please sign in to comment.