Skip to content

Commit 7c23201

Browse files
committed
Simplify internal codebase
1 parent 7d97b9d commit 7c23201

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/InnerList.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ private function filterIndex(int $index): int|null
125125

126126
public function replace(int $index, Item|ByteSequence|Token|bool|int|float|string|null $element): void
127127
{
128-
$offset = $this->filterIndex($index);
129-
if (null === $offset || !$this->hasIndex($offset)) {
128+
if (!$this->hasIndex($index)) {
130129
throw InvalidOffset::dueToIndexNotFound($index);
131130
}
132131

133-
$this->elements[$offset] = self::convertItem($element);
132+
$this->elements[$this->filterIndex($index)] = self::convertItem($element);
134133
}
135134

136135
public function remove(int ...$indexes): void

src/OrderedList.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ public function insert(
125125

126126
public function replace(int $index, InnerList|Item|ByteSequence|Token|bool|int|float|string $element): void
127127
{
128-
$offset = $this->filterIndex($index);
129-
if (null === $offset || !$this->hasIndex($offset)) {
128+
if (!$this->hasIndex($index)) {
130129
throw InvalidOffset::dueToIndexNotFound($index);
131130
}
132131

133-
$this->elements[$offset] = self::filterElement($element);
132+
$this->elements[$this->filterIndex($index)] = self::filterElement($element);
134133
}
135134

136135
public function remove(int ...$indexes): void

0 commit comments

Comments
 (0)