Skip to content

Commit

Permalink
Improve filtering of items
Browse files Browse the repository at this point in the history
  • Loading branch information
arogachev committed Dec 6, 2023
1 parent 6860c53 commit 184a797
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/ItemsStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,7 @@ private function fillChildrenRecursive(string $name, array &$result): void
*/
private function filterRoles(array $items): array
{
return array_filter(
$this->getRoles(),
static fn (Permission|Role $item): bool => array_key_exists($item->getName(), $items),
);
return array_filter($items, static fn (Permission|Role $item): bool => $item instanceof Role);
}

/**
Expand All @@ -517,9 +514,6 @@ private function filterRoles(array $items): array
*/
private function filterPermissions(array $items): array
{
return array_filter(
$this->getPermissions(),
static fn (Permission|Role $permissionItem): bool => array_key_exists($permissionItem->getName(), $items),
);
return array_filter($items, static fn (Permission|Role $item): bool => $item instanceof Permission);
}
}

0 comments on commit 184a797

Please sign in to comment.