Lines 90.54% 67 / 74
Functions and Methods 73.07% 19 / 26
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ThinnedScope 90.54% 67 / 74 73.07% 19 / 26 27.62 0.00% 0 / 1
 __construct 100.00% 24 / 24 100.00% 1 / 1 1
 ensureValid 50.00% 1 / 2 0.00% 0 / 1 2.50
 getProvider 0.00% 0 / 1 0.00% 0 / 1 2
 getShortName 0.00% 0 / 1 0.00% 0 / 1 2
 getEmailFrom 100.00% 1 / 1 100.00% 1 / 1 1
 isEmailRequired 100.00% 1 / 1 100.00% 1 / 1 1
 isTelephoneActivated 100.00% 1 / 1 100.00% 1 / 1 1
 isTelephoneRequired 100.00% 1 / 1 100.00% 1 / 1 1
 isCustomTextfieldActivated 100.00% 1 / 1 100.00% 1 / 1 1
 isCustomTextfieldRequired 100.00% 1 / 1 100.00% 1 / 1 1
 getCustomTextfieldLabel 100.00% 1 / 1 100.00% 1 / 1 1
 isCustomTextfield2Activated 100.00% 1 / 1 100.00% 1 / 1 1
 isCustomTextfield2Required 100.00% 1 / 1 100.00% 1 / 1 1
 getCustomTextfield2Label 100.00% 1 / 1 100.00% 1 / 1 1
 isCaptchaActivatedRequired 0.00% 0 / 1 0.00% 0 / 1 2
 getInfoForAppointment 0.00% 0 / 1 0.00% 0 / 1 2
 getInfoForAllAppointments 0.00% 0 / 1 0.00% 0 / 1 2
 getSlotsPerAppointment 100.00% 1 / 1 100.00% 1 / 1 1
 getAppointmentsPerMail 100.00% 1 / 1 100.00% 1 / 1 1
 getWhitelistedMails 100.00% 1 / 1 100.00% 1 / 1 1
 getReservationDuration 100.00% 1 / 1 100.00% 1 / 1 1
 getActivationDuration 100.00% 1 / 1 100.00% 1 / 1 1
 getHint 0.00% 0 / 1 0.00% 0 / 1 2
 isRebookingDisabled 100.00% 1 / 1 100.00% 1 / 1 1
 toArray 100.00% 25 / 25 100.00% 1 / 1 1
 jsonSerialize 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace BO\Zmscitizenapi\Models;
6
7use BO\Zmscitizenapi\Models\ThinnedProvider;
8use BO\Zmsentities\Schema\Entity;
9use InvalidArgumentException;
10use JsonSerializable;
11
12class ThinnedScope extends Entity implements JsonSerializable
13{
14    public static $schema = 'citizenapi/thinnedScope.json';
15    public int $id;
16    public ?ThinnedProvider $provider;
17    public ?string $shortName;
18    public ?string $emailFrom;
19    public ?bool $emailRequired;
20    public ?bool $telephoneActivated;
21    public ?bool $telephoneRequired;
22    public ?bool $customTextfieldActivated;
23    public ?bool $customTextfieldRequired;
24    public ?string $customTextfieldLabel;
25    public ?bool $customTextfield2Activated;
26    public ?bool $customTextfield2Required;
27    public ?string $customTextfield2Label;
28    public ?bool $captchaActivatedRequired;
29    public ?string $infoForAppointment;
30    public ?string $infoForAllAppointments;
31    public ?string $slotsPerAppointment;
32    public ?string $appointmentsPerMail;
33    public ?string $whitelistedMails;
34    public ?int $reservationDuration;
35    public ?int $activationDuration;
36    public ?string $hint;
37    public ?bool $rebookingDisabled;
38
39    public function __construct(int $id = 0, ?ThinnedProvider $provider = null, ?string $shortName = null, ?string $emailFrom = null, ?bool $emailRequired = null, ?bool $telephoneActivated = null, ?bool $telephoneRequired = null, ?bool $customTextfieldActivated = null, ?bool $customTextfieldRequired = null, ?string $customTextfieldLabel = null, ?bool $customTextfield2Activated = null, ?bool $customTextfield2Required = null, ?string $customTextfield2Label = null, ?bool $captchaActivatedRequired = null, ?string $infoForAppointment = null, ?string $infoForAllAppointments = null, ?string $slotsPerAppointment = null, ?string $appointmentsPerMail = null, ?string $whitelistedMails = null, ?int $reservationDuration = null, ?int $activationDuration = null, ?string $hint = null, ?bool $rebookingDisabled = null)
40    {
41        $this->id = $id;
42        $this->provider = $provider;
43        $this->shortName = $shortName;
44        $this->emailFrom = $emailFrom;
45        $this->emailRequired = $emailRequired;
46        $this->telephoneActivated = $telephoneActivated;
47        $this->telephoneRequired = $telephoneRequired;
48        $this->customTextfieldActivated = $customTextfieldActivated;
49        $this->customTextfieldRequired = $customTextfieldRequired;
50        $this->customTextfieldLabel = $customTextfieldLabel;
51        $this->customTextfield2Activated = $customTextfield2Activated;
52        $this->customTextfield2Required = $customTextfield2Required;
53        $this->customTextfield2Label = $customTextfield2Label;
54        $this->captchaActivatedRequired = $captchaActivatedRequired;
55        $this->infoForAppointment = $infoForAppointment;
56        $this->infoForAllAppointments = $infoForAllAppointments;
57        $this->slotsPerAppointment = $slotsPerAppointment;
58        $this->appointmentsPerMail = $appointmentsPerMail;
59        $this->whitelistedMails = $whitelistedMails;
60        $this->reservationDuration = $reservationDuration;
61        $this->activationDuration = $activationDuration;
62        $this->hint = $hint;
63        $this->rebookingDisabled = $rebookingDisabled;
64        $this->ensureValid();
65    }
66
67    /**
68     * @return void
69     */
70    private function ensureValid()
71    {
72        if (!$this->testValid()) {
73            throw new InvalidArgumentException("The provided data is invalid according to the schema.");
74        }
75    }
76
77    /** @psalm-api */
78    public function getProvider(): ?ThinnedProvider
79    {
80        return $this->provider;
81    }
82
83    /** @psalm-api */
84    public function getShortName(): ?string
85    {
86        return $this->shortName;
87    }
88
89    public function getEmailFrom(): ?string
90    {
91        return $this->emailFrom;
92    }
93
94    public function isEmailRequired(): ?bool
95    {
96        return $this->emailRequired;
97    }
98
99    public function isTelephoneActivated(): ?bool
100    {
101        return $this->telephoneActivated;
102    }
103
104    public function isTelephoneRequired(): ?bool
105    {
106        return $this->telephoneRequired;
107    }
108
109    public function isCustomTextfieldActivated(): ?bool
110    {
111        return $this->customTextfieldActivated;
112    }
113
114    public function isCustomTextfieldRequired(): ?bool
115    {
116        return $this->customTextfieldRequired;
117    }
118
119    public function getCustomTextfieldLabel(): ?string
120    {
121        return $this->customTextfieldLabel;
122    }
123
124    public function isCustomTextfield2Activated(): ?bool
125    {
126        return $this->customTextfield2Activated;
127    }
128
129    public function isCustomTextfield2Required(): ?bool
130    {
131        return $this->customTextfield2Required;
132    }
133
134    public function getCustomTextfield2Label(): ?string
135    {
136        return $this->customTextfield2Label;
137    }
138
139    /** @psalm-api */
140    public function isCaptchaActivatedRequired(): ?bool
141    {
142        return $this->captchaActivatedRequired;
143    }
144
145    /** @psalm-api */
146    public function getInfoForAppointment(): ?string
147    {
148        return $this->infoForAppointment;
149    }
150
151    /** @psalm-api */
152    public function getInfoForAllAppointments(): ?string
153    {
154        return $this->infoForAllAppointments;
155    }
156
157    public function getSlotsPerAppointment(): ?string
158    {
159        return $this->slotsPerAppointment;
160    }
161
162    public function getAppointmentsPerMail(): ?string
163    {
164        return $this->appointmentsPerMail;
165    }
166
167    public function getWhitelistedMails(): ?string
168    {
169        return $this->whitelistedMails;
170    }
171
172    public function getReservationDuration(): ?int
173    {
174        return $this->reservationDuration;
175    }
176
177    public function getActivationDuration(): ?int
178    {
179        return $this->activationDuration;
180    }
181
182    /** @psalm-api */
183    public function getHint(): ?string
184    {
185        return $this->hint;
186    }
187
188    public function isRebookingDisabled(): bool
189    {
190        return $this->rebookingDisabled === true;
191    }
192
193    public function toArray(): array
194    {
195        return [
196            'id' => $this->id,
197            'provider' => $this->provider,
198            'shortName' => $this->shortName,
199            'emailFrom' => $this->emailFrom,
200            'emailRequired' => $this->emailRequired,
201            'telephoneActivated' => $this->telephoneActivated,
202            'telephoneRequired' => $this->telephoneRequired,
203            'customTextfieldActivated' => $this->customTextfieldActivated,
204            'customTextfieldRequired' => $this->customTextfieldRequired,
205            'customTextfieldLabel' => $this->customTextfieldLabel,
206            'customTextfield2Activated' => $this->customTextfield2Activated,
207            'customTextfield2Required' => $this->customTextfield2Required,
208            'customTextfield2Label' => $this->customTextfield2Label,
209            'captchaActivatedRequired' => $this->captchaActivatedRequired,
210            'infoForAppointment' => $this->infoForAppointment,
211            'infoForAllAppointments' => $this->infoForAllAppointments,
212            'slotsPerAppointment' => $this->slotsPerAppointment,
213            'appointmentsPerMail' => $this->appointmentsPerMail,
214            'whitelistedMails' => $this->whitelistedMails,
215            'reservationDuration' => $this->reservationDuration,
216            'activationDuration' => $this->activationDuration,
217            'hint' => $this->hint,
218            'rebookingDisabled' => $this->rebookingDisabled,
219        ];
220    }
221
222    #[\Override]
223    public function jsonSerialize(): mixed
224    {
225        return $this->toArray();
226    }
227}