1 | <?php |
||
12 | class OpeningHoursForDay implements ArrayAccess, Countable, IteratorAggregate |
||
13 | { |
||
14 | /** @var \Spatie\OpeningHours\TimeRange[] */ |
||
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) |
||
57 | |||
58 | protected function findNextOpenInWorkingHours(Time $time, TimeRange $timeRange) |
||
64 | |||
65 | protected function findNextOpenInFreeTime(Time $time, TimeRange $timeRange, TimeRange &$prevTimeRange = null) |
||
66 | { |
||
67 | $timeOffRange = $prevTimeRange ? |
||
68 | TimeRange::fromString($prevTimeRange->end().'-'.$timeRange->start()) : |
||
69 | TimeRange::fromString('00:00-'.$timeRange->start()); |
||
70 | |||
71 | if ($timeOffRange->containsTime($time) || $timeOffRange->start()->isSame($time)) { |
||
72 | return $timeRange->start(); |
||
73 | } |
||
74 | |||
75 | $prevTimeRange = $timeRange; |
||
76 | } |
||
77 | |||
78 | public function offsetExists($offset): bool |
||
82 | |||
83 | public function offsetGet($offset) |
||
87 | |||
88 | public function offsetSet($offset, $value) |
||
92 | |||
93 | public function offsetUnset($offset) |
||
97 | |||
98 | public function count(): int |
||
102 | |||
103 | public function getIterator() |
||
107 | |||
108 | public function isEmpty(): bool |
||
112 | |||
113 | public function map(callable $callback): array |
||
117 | |||
118 | protected function guardAgainstTimeRangeOverlaps(array $openingHours) |
||
126 | |||
127 | public function __toString() |
||
136 | } |
||
137 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.