67 lines
1.2 KiB
PHP
67 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use App\Traits\Enums\BaseEnum;
|
|
|
|
enum Width: int
|
|
{
|
|
use BaseEnum;
|
|
|
|
case half = 1;
|
|
case full = 2;
|
|
|
|
/**
|
|
* Optionnal labels definition.
|
|
*
|
|
* @phpstan-ignore-next-line
|
|
*/
|
|
private const LABELS = [
|
|
self::half->name => 'enums.width.half',
|
|
self::full->name => 'enums.width.full',
|
|
];
|
|
|
|
|
|
/**
|
|
* Custom percent width value
|
|
*/
|
|
private const PERCENTVALUE = [
|
|
self::half->name => '50 %',
|
|
self::full->name => '100 %'
|
|
];
|
|
|
|
/**
|
|
* Get percent width value
|
|
*
|
|
* @return string
|
|
*/
|
|
public function percentValue(): string
|
|
{
|
|
return self::PERCENTVALUE[$this->name];
|
|
}
|
|
|
|
|
|
/**
|
|
* Custom dimension validation for the enum
|
|
*/
|
|
private const DIMVALIDATION = [
|
|
self::half->name => [
|
|
'width' => 600,
|
|
'height' => 500
|
|
],
|
|
self::full->name => [
|
|
'width' => 1300,
|
|
'height' => 500
|
|
],
|
|
];
|
|
|
|
/**
|
|
* Get percent width value
|
|
*
|
|
* @return array
|
|
*/
|
|
public function dimValidation(): array
|
|
{
|
|
return self::DIMVALIDATION[$this->name];
|
|
}
|
|
}
|