Skip to content

Commit 111f67b

Browse files
authored
Simplify keys call (#51876)
1 parent 1ca3acf commit 111f67b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Illuminate/Collections/Collection.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -1129,13 +1129,13 @@ public function before($value, $strict = false)
11291129
return null;
11301130
}
11311131

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

11341134
if ($position === 0) {
11351135
return null;
11361136
}
11371137

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

11411141
/**
@@ -1153,13 +1153,13 @@ public function after($value, $strict = false)
11531153
return null;
11541154
}
11551155

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

1158-
if ($position === $this->keys()->count() - 1) {
1158+
if ($position === $keys->count() - 1) {
11591159
return null;
11601160
}
11611161

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

11651165
/**

0 commit comments

Comments
 (0)