Skip to content

Commit

Permalink
prevent calling ->end() on root node (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored Jul 30, 2024
1 parent 2e52bd5 commit d813fdb
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 d813fdb

Please sign in to comment.