1 | <?php namespace VojtaSvoboda\Reservations\Facades; |
||
25 | class ReservationsFacade |
||
26 | { |
||
27 | /** @var Reservation $reservations */ |
||
28 | private $reservations; |
||
29 | |||
30 | /** @var Status $statuses */ |
||
31 | private $statuses; |
||
32 | |||
33 | /** @var DatesResolver $datesResolver */ |
||
34 | private $datesResolver; |
||
35 | |||
36 | /** @var array $returningUsersCache */ |
||
37 | private $returningUsersCache; |
||
38 | |||
39 | /** @var ReservationMailer $mailer */ |
||
40 | private $mailer; |
||
41 | |||
42 | /** @var ReservationAdminMailer $adminMailer */ |
||
43 | private $adminMailer; |
||
44 | |||
45 | /** |
||
46 | * ReservationsFacade constructor. |
||
47 | * |
||
48 | * @param Reservation $reservations |
||
49 | * @param Status $statuses |
||
50 | * @param DatesResolver $resolver |
||
51 | * @param ReservationMailer $mailer |
||
52 | * @param ReservationAdminMailer $adminMailer |
||
53 | */ |
||
54 | 9 | public function __construct( |
|
64 | |||
65 | /** |
||
66 | * Create and store reservation. |
||
67 | * |
||
68 | * @param array $data |
||
69 | * |
||
70 | * @return Reservation $reservation |
||
71 | * |
||
72 | * @throws ApplicationException |
||
73 | * @throws ValidationException |
||
74 | */ |
||
75 | 8 | public function storeReservation($data) |
|
91 | |||
92 | /** |
||
93 | 6 | * Send mail to client and admin. |
|
94 | * |
||
95 | 6 | * @param Reservation $reservation |
|
96 | */ |
||
97 | public function sendMails($reservation) |
||
108 | |||
109 | /** |
||
110 | * Get all reservations. |
||
111 | * |
||
112 | * @return Collection |
||
113 | */ |
||
114 | public function getReservations() |
||
118 | |||
119 | /** |
||
120 | * Get all active (not cancelled) reservations. |
||
121 | * |
||
122 | * @return Collection |
||
123 | */ |
||
124 | public function getActiveReservations() |
||
128 | |||
129 | /** |
||
130 | * Get all reserved time slots. |
||
131 | * |
||
132 | * @return array |
||
133 | */ |
||
134 | public function getReservedDates() |
||
140 | |||
141 | /** |
||
142 | * Get all reservations by given date interval. |
||
143 | * |
||
144 | * @param Carbon $since Date from. |
||
145 | * @param Carbon $till Date to. |
||
146 | * |
||
147 | * @return mixed |
||
148 | */ |
||
149 | public function getReservationsByInterval(Carbon $since, Carbon $till) |
||
150 | 6 | { |
|
151 | return $this->reservations->whereBetween('date', [$since, $till])->get(); |
||
152 | 6 | } |
|
153 | |||
154 | /** |
||
155 | * Get reservations count by one email. |
||
156 | * |
||
157 | * @param $email |
||
158 | * |
||
159 | * @return int |
||
160 | */ |
||
161 | public function getReservationsCountByMail($email) |
||
162 | 1 | { |
|
163 | return $this->reservations->where('email', $email)->notCancelled()->count(); |
||
164 | } |
||
165 | 1 | ||
166 | 1 | /** |
|
167 | * Is user returning or not? You have to set this parameter at Backend Reservations setting. |
||
168 | * |
||
169 | * @param $email |
||
170 | * |
||
171 | 1 | * @return bool |
|
172 | */ |
||
173 | 1 | public function isUserReturning($email) |
|
199 | |||
200 | /** |
||
201 | * Bulk reservation state change. |
||
202 | * |
||
203 | * @param array $ids |
||
204 | * @param string $ident |
||
205 | */ |
||
206 | public function bulkStateChange($ids, $ident) |
||
226 | |||
227 | /** |
||
228 | * Bulk reservations delete. |
||
229 | * |
||
230 | * @param array $ids |
||
231 | */ |
||
232 | public function bulkDelete($ids) |
||
245 | |||
246 | /** |
||
247 | 9 | * Transform date and time to DateTime string. |
|
248 | 1 | * |
|
249 | * @param $data |
||
250 | 8 | * |
|
251 | 1 | * @return Carbon |
|
252 | * |
||
253 | * @throws ApplicationException |
||
254 | 7 | */ |
|
255 | public function transformDateTime($data) |
||
271 | |||
272 | /** |
||
273 | * Validate reservation date and time. |
||
274 | 6 | * |
|
275 | 1 | * @param Reservation $reservation |
|
276 | * |
||
277 | 6 | * @return bool |
|
278 | */ |
||
279 | public function validateReservation(Reservation $reservation) |
||
285 | |||
286 | 6 | /** |
|
287 | * Returns if given date is available. |
||
288 | * |
||
289 | 6 | * @param Carbon $date |
|
290 | * @param int $exceptId Except reservation ID. |
||
291 | * |
||
292 | 6 | * @return bool |
|
293 | 6 | */ |
|
294 | 6 | public function isDateAvailable($date, $exceptId = null) |
|
309 | |||
310 | /** |
||
311 | * Check reservations amount limit per time. |
||
312 | 6 | * |
|
313 | * @throws ApplicationException |
||
314 | 6 | */ |
|
315 | private function checkLimits() |
||
321 | |||
322 | /** |
||
323 | * Try to find some reservation in less then given limit (default 30 seconds). |
||
324 | * |
||
325 | * @return boolean |
||
326 | */ |
||
327 | public function isCreatedWhileAgo() |
||
338 | } |
||
339 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.