1 | <?php |
||
12 | class OpeningHoursForDay implements ArrayAccess, Countable, IteratorAggregate |
||
13 | { |
||
14 | /** @var array */ |
||
15 | protected $openingHours = []; |
||
16 | |||
17 | public static function fromStrings(array $strings) |
||
18 | { |
||
19 | $openingHoursForDay = new static(); |
||
20 | |||
21 | $timeRanges = Arr::map($strings, function ($string) { |
||
22 | return TimeRange::fromString($string); |
||
23 | }); |
||
24 | |||
25 | $openingHoursForDay->guardAgainstTimeRangeOverlaps($timeRanges); |
||
26 | |||
27 | $openingHoursForDay->openingHours = $timeRanges; |
||
28 | |||
29 | return $openingHoursForDay; |
||
30 | } |
||
31 | |||
32 | public function isOpenAt(Time $time) |
||
42 | |||
43 | public function nextOpen(Time $time) |
||
72 | |||
73 | public function offsetExists($offset): bool |
||
77 | |||
78 | public function offsetGet($offset) |
||
82 | |||
83 | public function offsetSet($offset, $value) |
||
87 | |||
88 | public function offsetUnset($offset) |
||
92 | |||
93 | public function count(): int |
||
97 | |||
98 | public function getIterator() |
||
102 | |||
103 | protected function guardAgainstTimeRangeOverlaps(array $openingHours) |
||
111 | } |
||
112 |