33 lines
598 B
PHP
33 lines
598 B
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
enum MatchOutcome: string
|
|
{
|
|
case Home = 'home';
|
|
case Draw = 'draw';
|
|
case Away = 'away';
|
|
|
|
public function label(): string
|
|
{
|
|
return match ($this) {
|
|
self::Home => 'Home win',
|
|
self::Draw => 'Draw',
|
|
self::Away => 'Away win',
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public static function options(): array
|
|
{
|
|
$options = [];
|
|
|
|
foreach (self::cases() as $case) {
|
|
$options[$case->value] = $case->label();
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
}
|