Skip to content

Commit 6cb52b2

Browse files
authored
Replace foreach by collection contains in Request class (#39857)
1 parent 8d7c7a4 commit 6cb52b2

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

src/Illuminate/Http/Request.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,7 @@ public function is(...$patterns)
208208
{
209209
$path = $this->decodedPath();
210210

211-
foreach ($patterns as $pattern) {
212-
if (Str::is($pattern, $path)) {
213-
return true;
214-
}
215-
}
216-
217-
return false;
211+
return collect($patterns)->contains(fn ($pattern) => Str::is($pattern, $path));
218212
}
219213

220214
/**
@@ -238,13 +232,7 @@ public function fullUrlIs(...$patterns)
238232
{
239233
$url = $this->fullUrl();
240234

241-
foreach ($patterns as $pattern) {
242-
if (Str::is($pattern, $url)) {
243-
return true;
244-
}
245-
}
246-
247-
return false;
235+
return collect($patterns)->contains(fn ($pattern) => Str::is($pattern, $url));
248236
}
249237

250238
/**

0 commit comments

Comments
 (0)