Skip to content

Commit

Permalink
Simplify keys call (#51876)
Browse files Browse the repository at this point in the history
  • Loading branch information
bert-w authored Jun 21, 2024
1 parent 1ca3acf commit 111f67b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,13 @@ public function before($value, $strict = false)
return null;
}

$position = $this->keys()->search($key);
$position = ($keys = $this->keys())->search($key);

if ($position === 0) {
return null;
}

return $this->get($this->keys()->get($position - 1));
return $this->get($keys->get($position - 1));
}

/**
Expand All @@ -1153,13 +1153,13 @@ public function after($value, $strict = false)
return null;
}

$position = $this->keys()->search($key);
$position = ($keys = $this->keys())->search($key);

if ($position === $this->keys()->count() - 1) {
if ($position === $keys->count() - 1) {
return null;
}

return $this->get($this->keys()->get($position + 1));
return $this->get($keys->get($position + 1));
}

/**
Expand Down

0 comments on commit 111f67b

Please sign in to comment.