Skip to content

Commit

Permalink
Fix: Return array with node from getNeighborsAndSelf() when node is root
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 28, 2023
1 parent 62ed455 commit d844ec0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Node/NodeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public function getNeighbors(): array

public function getNeighborsAndSelf(): array
{
if (null === $this->parent) {
return [
$this,
];
}

return $this->getParent()->getChildren();
}

Expand Down

0 comments on commit d844ec0

Please sign in to comment.