| | |
| | | } |
| | | |
| | | class DayOfWeek extends Enumeration { |
| | | protected string $day; |
| | | protected string|array $day; |
| | | protected array $allowedDay = [ |
| | | 'monday' => 'https://schema.org/Monday', |
| | | 'tuesday' => 'https://schema.org/Tuesday', |
| | |
| | | 'sunday' => 'https://schema.org/Sunday', |
| | | 'publicHolidays' => 'https://schema.org/PublicHolidays' |
| | | ]; |
| | | public function setDay(array|string $day) { |
| | | if (!is_array($day)) { |
| | | $day = [$day]; |
| | | } |
| | | $day = array_filter($day, function($d) { |
| | | if (!array_key_exists(strtolower($d), $this->allowedDay)) { |
| | | error_log('Invalid day attempted: '.$d); |
| | | return false; |
| | | } |
| | | return true; |
| | | }); |
| | | if (empty($day)) { |
| | | return; |
| | | } |
| | | $this->day = count($day) === 1 ? $day[0] : $day; |
| | | } |
| | | |
| | | } |