collection-crud/src/Enum/SlotKey.php

75 lines
1.6 KiB
PHP

<?php declare(strict_types=1);
namespace App\Enum;
enum SlotKey: string {
case PCIE_X16 = 'PCIe x16';
case PCIE_X8 = 'PCIe x8';
case PCIE_X4 = 'PCIe x4';
case PCIE_X1 = 'PCIe x1';
case AGP_UNIVERSAL = 'Universal AGP';
case AGP_33V = '3.3V AGP';
case AGP_15V = '1.5V AGP';
case AGP_PRO_UNIVERSAL = 'Universal AGP Pro';
case AGP_PRO_33V = '3.3V AGP Pro';
case AGP_PRO_15V = '1.5V AGP Pro';
case PCI_5V = '5V 32-bit PCI';
case PCI_33V = '3.3V 32-bit PCI';
case PCI_UNIVERSAL = 'Universal 32-bit PCI';
case PCI_64_5V = '5V 64-bit PCI';
case PCI_64_33V = '3.3V 64-bit PCI';
case PCI_64_UNIVERSAL = 'Universal 64-bit PCI';
case PCI_X = 'PCI-X';
case ISA_VLB = 'VESA Local Bus';
case ISA_8 = '8-bit ISA';
case ISA_16 = '16-bit ISA';
public static function getCases(): array
{
$cases = self::cases();
return array_map(static fn(UnitEnum $case) => $case->name, $cases);
}
public static function getValues(): array
{
$cases = self::cases();
return array_map(static fn(UnitEnum $case) => $case->value, $cases);
}
public static function getGroups(): array
{
$filter = static fn (string $starts_with) =>
array_filter(self::cases(), fn (SlotKey $case) =>
str_starts_with($case->name, $starts_with)
);
return [
'PCI Express' => $filter('PCIE_'),
'AGP' => [
self::AGP_UNIVERSAL,
self::AGP_33V,
self::AGP_15V,
],
'PCI 32-bit' => [
self::PCI_UNIVERSAL,
self::PCI_5V,
self::PCI_33V,
],
'PCI 64-bit' => [
self::PCI_X,
self::PCI_64_UNIVERSAL,
self::PCI_64_33V,
self::PCI_64_5V,
],
'ISA' => [
self::ISA_16,
self::ISA_8,
self::ISA_VLB,
]
];
}
}