buckets/app/Enums/BucketTypeEnum.php

38 lines
871 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Enums;
enum BucketTypeEnum: string
{
case NEED = 'need';
case WANT = 'want';
case OVERFLOW = 'overflow';
public function getLabel(): string
{
return match ($this) {
self::NEED => 'Need',
self::WANT => 'Want',
self::OVERFLOW => 'Overflow',
};
}
public static function values(): array
{
return array_column(self::cases(), 'value');
}
/**
* Get valid allocation types for this bucket type.
*
* @return BucketAllocationTypeEnum[]
*/
public function getAllowedAllocationTypes(): array
{
return match ($this) {
self::NEED, self::WANT => [BucketAllocationTypeEnum::FIXED_LIMIT, BucketAllocationTypeEnum::PERCENTAGE],
self::OVERFLOW => [BucketAllocationTypeEnum::UNLIMITED],
};
}
}