Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
16 / 16 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
AppointmentList | |
100.00% |
16 / 16 |
|
100.00% |
4 / 4 |
12 | |
100.00% |
1 / 1 |
getByDate | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
4 | |||
hasDateScope | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
hasAppointment | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
3 | |||
getCalculatedSlotCount | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsentities\Collection; |
4 | |
5 | use BO\Zmsentities\Appointment; |
6 | |
7 | class AppointmentList extends Base |
8 | { |
9 | const ENTITY_CLASS = '\BO\Zmsentities\Appointment'; |
10 | |
11 | public function getByDate($date) |
12 | { |
13 | foreach ($this as $item) { |
14 | if ($item['date'] == $date) { |
15 | return $item instanceof Appointment ? $item : new Appointment($item); |
16 | } |
17 | } |
18 | return false; |
19 | } |
20 | |
21 | public function hasDateScope($date, $scopeId) |
22 | { |
23 | $item = $this->getByDate($date); |
24 | if ($item && $item->toProperty()->scope->id->get() == $scopeId) { |
25 | return true; |
26 | } |
27 | return false; |
28 | } |
29 | |
30 | public function hasAppointment(\BO\Zmsentities\Appointment $appointment) |
31 | { |
32 | foreach ($this as $appointmentItem) { |
33 | if ($appointmentItem->isMatching($appointment)) { |
34 | return true; |
35 | } |
36 | } |
37 | return false; |
38 | } |
39 | |
40 | public function getCalculatedSlotCount() |
41 | { |
42 | $slotCount = 0; |
43 | foreach ($this as $appointmentItem) { |
44 | $slotCount += $appointmentItem->getSlotCount(); |
45 | } |
46 | return $slotCount; |
47 | } |
48 | } |