Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
94.74% |
18 / 19 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| AvailableCalendar | |
94.74% |
18 / 19 |
|
75.00% |
3 / 4 |
4.00 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| ensureValid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace BO\Zmscitizenapi\Models; |
| 6 | |
| 7 | use BO\Zmsentities\Schema\Entity; |
| 8 | use JsonSerializable; |
| 9 | |
| 10 | class AvailableCalendar extends Entity implements JsonSerializable |
| 11 | { |
| 12 | public static $schema = 'citizenapi/availableCalendar.json'; |
| 13 | public string $startDate = ''; |
| 14 | public string $endDate = ''; |
| 15 | public string $slotsStartDate = ''; |
| 16 | public string $slotsEndDate = ''; |
| 17 | public ?string $prevBookableDate = null; |
| 18 | public ?string $nextBookableDate = null; |
| 19 | public array $availableDays = []; |
| 20 | |
| 21 | public function __construct( |
| 22 | string $startDate, |
| 23 | string $endDate, |
| 24 | array $availableDays = [], |
| 25 | ?string $slotsStartDate = null, |
| 26 | ?string $slotsEndDate = null, |
| 27 | ?string $prevBookableDate = null, |
| 28 | ?string $nextBookableDate = null |
| 29 | ) { |
| 30 | $this->startDate = $startDate; |
| 31 | $this->endDate = $endDate; |
| 32 | $this->slotsStartDate = $slotsStartDate ?? $startDate; |
| 33 | $this->slotsEndDate = $slotsEndDate ?? $endDate; |
| 34 | $this->prevBookableDate = $prevBookableDate; |
| 35 | $this->nextBookableDate = $nextBookableDate; |
| 36 | $this->availableDays = $availableDays; |
| 37 | $this->ensureValid(); |
| 38 | } |
| 39 | |
| 40 | public function ensureValid(): void |
| 41 | { |
| 42 | $this->testValid(); |
| 43 | } |
| 44 | |
| 45 | public function toArray(): array |
| 46 | { |
| 47 | return [ |
| 48 | 'startDate' => $this->startDate, |
| 49 | 'endDate' => $this->endDate, |
| 50 | 'slotsStartDate' => $this->slotsStartDate, |
| 51 | 'slotsEndDate' => $this->slotsEndDate, |
| 52 | 'prevBookableDate' => $this->prevBookableDate, |
| 53 | 'nextBookableDate' => $this->nextBookableDate, |
| 54 | 'availableDays' => $this->availableDays, |
| 55 | ]; |
| 56 | } |
| 57 | |
| 58 | #[\Override] |
| 59 | public function jsonSerialize(): mixed |
| 60 | { |
| 61 | return $this->toArray(); |
| 62 | } |
| 63 | } |