1 | <?php |
||
12 | abstract class AbstractDay implements DayInterface |
||
13 | { |
||
14 | /** |
||
15 | * The days of the week. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $daysOfWeek = array( |
||
20 | DayInterface::WEEK_DAY_MONDAY => 'Monday', |
||
21 | DayInterface::WEEK_DAY_TUESDAY => 'Tuesday', |
||
22 | DayInterface::WEEK_DAY_WEDNESDAY => 'Wednesday', |
||
23 | DayInterface::WEEK_DAY_THURSDAY => 'Thursday', |
||
24 | DayInterface::WEEK_DAY_FRIDAY => 'Friday', |
||
25 | DayInterface::WEEK_DAY_SATURDAY => 'Saturday', |
||
26 | DayInterface::WEEK_DAY_SUNDAY => 'Sunday', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * The day of week. |
||
31 | * |
||
32 | * @var integer |
||
33 | */ |
||
34 | protected $dayOfWeek; |
||
35 | |||
36 | /** |
||
37 | * The time intervals. |
||
38 | * |
||
39 | * @var TimeIntervalInterface[] |
||
40 | */ |
||
41 | protected $openingHoursIntervals; |
||
42 | |||
43 | /** |
||
44 | * Constructor. |
||
45 | * |
||
46 | * @param integer $dayOfWeek The day of week. |
||
47 | * @param TimeIntervalInterface[] $openingHoursIntervals The opening hours intervals. |
||
48 | */ |
||
49 | public function __construct($dayOfWeek, array $openingHoursIntervals) |
||
54 | |||
55 | /** |
||
56 | * {@inheritdoc} |
||
57 | */ |
||
58 | public function getDayOfWeek() |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function getDayOfWeekName() |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function getOpeningHoursIntervals() |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function getClosestOpeningHoursInterval(Time $time) |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function getNextOpeningHoursInterval(Time $time) |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function getOpeningTime() |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function getClosingTime() |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | public function isWithinOpeningHours(Time $time) |
||
158 | |||
159 | /** |
||
160 | * Set the day of week. |
||
161 | * |
||
162 | * @param int $dayOfWeek |
||
163 | * @throws \OutOfBoundsException If the given day is invalid. |
||
164 | */ |
||
165 | protected function setDayOfWeek($dayOfWeek) |
||
173 | |||
174 | /** |
||
175 | * Set the opening hours intervals. |
||
176 | * |
||
177 | * @param TimeIntervalInterface[] $openingHoursIntervals The opening hours intervals. |
||
178 | * @throws \InvalidArgumentException If no days are passed or invalid interval is passed. |
||
179 | */ |
||
180 | protected function setOpeningHoursIntervals(array $openingHoursIntervals) |
||
198 | |||
199 | /** |
||
200 | * Flatten the intervals that overlap. |
||
201 | * |
||
202 | * @param TimeIntervalInterface[] $openingHoursIntervals |
||
203 | * @return TimeIntervalInterface[] |
||
204 | */ |
||
205 | protected function flattenOpeningHoursIntervals(array $openingHoursIntervals) |
||
233 | } |
||
234 |