47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Enums;
|
|
|
|
use App\Services\WebsiteTranslations;
|
|
use Illuminate\Support\Collection;
|
|
|
|
enum DocumentationVersionStatus: int
|
|
{
|
|
case NotSupported = 0;
|
|
case Supported = 50;
|
|
case CurrentVersion = 100;
|
|
case FutureVersion = 150;
|
|
|
|
public function getTitle(?WebsiteTranslations $websiteTranslations = null): string
|
|
{
|
|
if (\is_null($websiteTranslations)) {
|
|
return __($this->getCodeForTranslation());
|
|
}
|
|
|
|
return $websiteTranslations->translate($this->getCodeForTranslation());
|
|
}
|
|
|
|
public function getCodeForTranslation(): string
|
|
{
|
|
return 'version-status.' . $this->name;
|
|
}
|
|
|
|
public static function toArray(): array
|
|
{
|
|
$items = [];
|
|
foreach (self::cases() as $item) {
|
|
$items[] = [
|
|
'name' => $item->name,
|
|
'value' => $item->value,
|
|
'title' => $item->getTitle(),
|
|
];
|
|
}
|
|
return $items;
|
|
}
|
|
|
|
public static function toCollection(): Collection
|
|
{
|
|
return collect(self::toArray());
|
|
}
|
|
}
|