36 lines
775 B
PHP
36 lines
775 B
PHP
<?php
|
|
|
|
namespace App\Enums\Recipes;
|
|
|
|
enum DifficultyEnum : int
|
|
{
|
|
case easy = 1;
|
|
case medium = 2;
|
|
case hard = 3;
|
|
|
|
public function label(): string
|
|
{
|
|
return static::getLabel($this);
|
|
}
|
|
|
|
public static function getLabel(self $value): string
|
|
{
|
|
return match ($value) {
|
|
self::easy => __('Easy'),
|
|
self::medium => __('Medium'),
|
|
self::hard => __('Hard'),
|
|
};
|
|
}
|
|
|
|
public static function getData(): array
|
|
{
|
|
$arrayEnum = [];
|
|
foreach (self::cases() as $key => $value) {
|
|
$arrayEnum = array_merge($arrayEnum, [[
|
|
"value" => $value->value,
|
|
"label" => $value->label()
|
|
]]);
|
|
}
|
|
return $arrayEnum;
|
|
}
|
|
}
|