ldc-legaulois/app/Enums/DepartaimantStatus.php

59 lines
1.2 KiB
PHP

<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* @method static self none()
* @method static self has()
* @method static self wants()
* @method static self gives()
*/
final class DepartaimantStatus extends BaseEnumRoutable
{
protected static function values(): array
{
return [
'none' => 0,
'has' => 1,
'gives' => 2,
'wants' => 3,
];
}
protected static function labels(): array
{
return [
'none' => __('Non possédé'),
'has' => __('Je possède'),
'gives' => __("J'échange"),
'wants' => __('Je cherche'),
];
}
public function __toString(): string
{
return (string)$this->label;
}
public static function toArray(): array
{
$array = [];
foreach (parent::toArray() as $enum) {
$array[$enum->getDefinition()] = [
'value' => $enum->value,
'label' => $enum->label
];
}
return $array;
}
public function jsonSerialize()
{
return [
'value' => $this->value,
'label' => \stripslashes($this->label)
];
}
}