array_filter(self::cases(), fn (CardBus $case) => str_starts_with($case->name, $starts_with) ); $pcie = $filter('PCIE_'); $agp = $filter('AGP_'); $pci = $filter('PCI_'); $isa = $filter('ISA_'); $pcie16 = array_filter($pcie, fn (CardBus $case) => str_ends_with($case->name, '_16')); $pcieOther = array_udiff($pcie, $pcie16, fn ($a, $b) => $a->name <=> $b->name); return [ 'PCI Express x16' => $pcie16, 'PCI Express Other' => $pcieOther, 'AGP' => $agp, 'PCI' => $pci, 'ISA' => $isa, ]; } }