Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace "array_intersect_key" with "intersectByKeys" #778

Merged
merged 1 commit into from
Aug 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,14 @@ private function prepareRegex(Collection $required, Collection $optional, $custo

private function formatMatches(array $matches, Collection $required, Collection $optional)
{
//Need to update Illuminate\Support to newer version to take advantage of
//intersectBykeys method on collections. Have to use this horrible array method until then!
return isset($matches) ? array_intersect_key(
$matches,
$required
->merge($optional)
//incase this was a custom regex search we need to add a custom key
->push('custom')
->flip()
->toArray()
) : [];
return collect($matches)
->intersectByKeys(
$required
->merge($optional)
//incase this was a custom regex search we need to add a custom key
->push('custom')
->flip()
)->all();
}

private function checkForCustomRegex(Collection $required, Collection $optional)
Expand Down