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 | /** |
| 8 | * @extends Base<\BO\Zmsentities\Appointment> |
| 9 | */ |
| 10 | class AppointmentList extends Base |
| 11 | { |
| 12 | public const ENTITY_CLASS = '\BO\Zmsentities\Appointment'; |
| 13 | |
| 14 | public function getByDate($date) |
| 15 | { |
| 16 | foreach ($this as $item) { |
| 17 | if ($item['date'] == $date) { |
| 18 | return $item instanceof Appointment ? $item : new Appointment($item); |
| 19 | } |
| 20 | } |
| 21 | return false; |
| 22 | } |
| 23 | |
| 24 | public function hasDateScope($date, $scopeId) |
| 25 | { |
| 26 | $item = $this->getByDate($date); |
| 27 | if ($item && $item->toProperty()->scope->id->get() == $scopeId) { |
| 28 | return true; |
| 29 | } |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | public function hasAppointment(\BO\Zmsentities\Appointment $appointment) |
| 34 | { |
| 35 | foreach ($this as $appointmentItem) { |
| 36 | if ($appointmentItem->isMatching($appointment)) { |
| 37 | return true; |
| 38 | } |
| 39 | } |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | public function getCalculatedSlotCount() |
| 44 | { |
| 45 | $slotCount = 0; |
| 46 | foreach ($this as $appointmentItem) { |
| 47 | $slotCount += $appointmentItem->getSlotCount(); |
| 48 | } |
| 49 | return $slotCount; |
| 50 | } |
| 51 | } |