Lines
94.73%
36 / 38
Methods
50.00%
2 / 4
Classes
0.00%
0 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 17 / 17 | 100.00% | 1 / 1 | 1 | ||
| ensureValid | 50.00% | 1 / 2 | 0.00% | 0 / 1 | 2.50 | ||
| toArray | 100.00% | 18 / 18 | 100.00% | 1 / 1 | 1 | ||
| jsonSerialize | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | ||
| 12 | class Office extends Entity implements JsonSerializable | |
| 13 | { | |
| 14 | public static $schema = 'citizenapi/office.json'; | |
| 15 | public int $id; | |
| 16 | public string $name; | |
| 17 | public ?array $address = null; | |
| 18 | public ?array $displayNameAlternatives = null; | |
| 19 | public ?bool $showAlternativeLocations = null; | |
| 20 | public ?string $organization = null; | |
| 21 | public ?string $organizationUnit = null; | |
| 22 | public ?int $slotTimeInMinutes = null; | |
| 23 | public ?array $geo = null; | |
| 24 | public ?array $disabledByServices = []; | |
| 25 | public int $priority = 1; | |
| 26 | public ?ThinnedScope $scope = null; | |
| 27 | public ?string $slotsPerAppointment = null; | |
| 28 | public ?int $parentId = null; | |
| 29 | public ?array $allowDisabledServicesMix = null; | |
| 30 | public ?array $sharedBookingOfficeIds = null; | |
| 31 | ||
| 32 | public function __construct( | |
| 33 | int $id, | |
| 34 | string $name, | |
| 35 | ?array $address = null, | |
| 36 | ?bool $showAlternativeLocations = null, | |
| 37 | ?array $displayNameAlternatives = null, | |
| 38 | ?string $organization = null, | |
| 39 | ?string $organizationUnit = null, | |
| 40 | ?int $slotTimeInMinutes = null, | |
| 41 | ?array $geo = null, | |
| 42 | ?array $disabledByServices = [], | |
| 43 | int $priority = 1, | |
| 44 | ?ThinnedScope $scope = null, | |
| 45 | ?string $slotsPerAppointment = null, | |
| 46 | ?int $parentId = null, | |
| 47 | ?array $allowDisabledServicesMix = null, | |
| 48 | ?array $sharedBookingOfficeIds = null | |
| 49 | ) { | |
| 50 | $this->id = $id; | |
| 51 | $this->name = $name; | |
| 52 | $this->address = $address; | |
| 53 | $this->showAlternativeLocations = $showAlternativeLocations; | |
| 54 | $this->displayNameAlternatives = $displayNameAlternatives; | |
| 55 | $this->organization = $organization; | |
| 56 | $this->organizationUnit = $organizationUnit; | |
| 57 | $this->slotTimeInMinutes = $slotTimeInMinutes; | |
| 58 | $this->geo = $geo; | |
| 59 | $this->scope = $scope; | |
| 60 | $this->priority = $priority; | |
| 61 | $this->disabledByServices = $disabledByServices; | |
| 62 | $this->slotsPerAppointment = $slotsPerAppointment; | |
| 63 | $this->parentId = $parentId; | |
| 64 | $this->allowDisabledServicesMix = $allowDisabledServicesMix; | |
| 65 | $this->sharedBookingOfficeIds = $sharedBookingOfficeIds; | |
| 66 | $this->ensureValid(); | |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * @return void | |
| 71 | */ | |
| 72 | private function ensureValid() | |
| 73 | { | |
| 74 | if (!$this->testValid()) { | |
| 75 | throw new InvalidArgumentException("The provided data is invalid according to the schema."); | |
| 76 | } | |
| 77 | } | |
| 78 | ||
| 79 | public function toArray(): array | |
| 80 | { | |
| 81 | return [ | |
| 82 | 'id' => $this->id, | |
| 83 | 'name' => $this->name, | |
| 84 | 'address' => $this->address, | |
| 85 | 'showAlternativeLocations' => $this->showAlternativeLocations, | |
| 86 | 'displayNameAlternatives' => $this->displayNameAlternatives, | |
| 87 | 'organization' => $this->organization, | |
| 88 | 'organizationUnit' => $this->organizationUnit, | |
| 89 | 'slotTimeInMinutes' => $this->slotTimeInMinutes, | |
| 90 | 'geo' => $this->geo, | |
| 91 | 'disabledByServices' => $this->disabledByServices, | |
| 92 | 'priority' => $this->priority, | |
| 93 | 'scope' => $this->scope?->toArray(), | |
| 94 | 'slotsPerAppointment' => $this->slotsPerAppointment, | |
| 95 | 'parentId' => $this->parentId, | |
| 96 | 'allowDisabledServicesMix' => $this->allowDisabledServicesMix, | |
| 97 | 'sharedBookingOfficeIds' => $this->sharedBookingOfficeIds, | |
| 98 | ]; | |
| 99 | } | |
| 100 | ||
| 101 | #[\Override] | |
| 102 | public function jsonSerialize(): mixed | |
| 103 | { | |
| 104 | return $this->toArray(); | |
| 105 | } | |
| 106 | } |