Skip to content

Commit

Permalink
Fix small bug in NaryNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Feb 26, 2020
1 parent 5e94567 commit 4c8cf5a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Node/NaryNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public function offsetSet($offset, $value): void
if (null === $offset) {
$this->add($value);
} else {
if ($this->capacity() - 1 < $offset) {
throw new OutOfBoundsException('The offset is out of range.');
if (0 !== $this->capacity()) {
if ($this->capacity() - 1 < $offset) {
throw new OutOfBoundsException('The offset is out of range.');
}
}

parent::offsetSet($offset, $value);
Expand Down

0 comments on commit 4c8cf5a

Please sign in to comment.