62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Enums;
|
|
|
|
use Kwaadpepper\Enum\BaseEnumRoutable;
|
|
|
|
/**
|
|
* @method static self none()
|
|
* @method static self mon()
|
|
* @method static self tue()
|
|
* @method static self wed()
|
|
* @method static self thu()
|
|
* @method static self fri()
|
|
* @method static self sat()
|
|
* @method static self sun()
|
|
*/
|
|
final class Days extends BaseEnumRoutable
|
|
{
|
|
protected static function values(): array
|
|
{
|
|
return [
|
|
'none' => 0,
|
|
'mon' => 1,
|
|
'tue' => 1 << 1,
|
|
'wed' => 1 << 2,
|
|
'thu' => 1 << 3,
|
|
'fri' => 1 << 4,
|
|
'sat' => 1 << 5,
|
|
'sun' => 1 << 6,
|
|
];
|
|
}
|
|
|
|
protected static function labels(): array
|
|
{
|
|
return [
|
|
'none' => __('None'),
|
|
'mon' => __('Monday'),
|
|
'tue' => __('Tuesday'),
|
|
'wed' => __('Wednesday'),
|
|
'thu' => __('Thursday'),
|
|
'fri' => __('Friday'),
|
|
'sat' => __('Saturday'),
|
|
'sun' => __('Sunday')
|
|
];
|
|
}
|
|
|
|
public function __toString(): string
|
|
{
|
|
return (string)$this->label;
|
|
}
|
|
|
|
/**
|
|
* Checks if days contain this day
|
|
*
|
|
* @param integer $days
|
|
* @return boolean
|
|
*/
|
|
public function has(int $days)
|
|
{
|
|
return (bool)($this->value & $days);
|
|
}
|
|
}
|