Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
87.80% |
36 / 41 |
|
66.67% |
10 / 15 |
CRAP | |
0.00% |
0 / 1 |
ThinnedScope | |
87.80% |
36 / 41 |
|
66.67% |
10 / 15 |
16.46 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
13 / 13 |
|
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 | |||
getEmailRequired | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTelephoneActivated | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTelephoneRequired | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCustomTextfieldActivated | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCustomTextfieldRequired | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getCustomTextfieldLabel | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCaptchaActivatedRequired | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDisplayInfo | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
toArray | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace BO\Zmscitizenapi\Models; |
6 | |
7 | use BO\Zmscitizenapi\Models\ThinnedProvider; |
8 | use BO\Zmsentities\Schema\Entity; |
9 | use InvalidArgumentException; |
10 | use JsonSerializable; |
11 | |
12 | class ThinnedScope extends Entity implements JsonSerializable |
13 | { |
14 | public static $schema = 'citizenapi/thinnedScope.json'; |
15 | /** @var int */ |
16 | public int $id; |
17 | /** @var ThinnedProvider|null */ |
18 | public ?ThinnedProvider $provider; |
19 | /** @var string|null */ |
20 | public ?string $shortName; |
21 | /** @var string|null */ |
22 | public ?string $emailFrom; |
23 | /** @var bool|null */ |
24 | public ?bool $emailRequired; |
25 | /** @var bool|null */ |
26 | public ?bool $telephoneActivated; |
27 | /** @var bool|null */ |
28 | public ?bool $telephoneRequired; |
29 | /** @var bool|null */ |
30 | public ?bool $customTextfieldActivated; |
31 | /** @var bool|null */ |
32 | public ?bool $customTextfieldRequired; |
33 | /** @var string|null */ |
34 | public ?string $customTextfieldLabel; |
35 | /** @var bool|null */ |
36 | public ?bool $captchaActivatedRequired; |
37 | /** @var string|null */ |
38 | public ?string $displayInfo; |
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 $captchaActivatedRequired = null, ?string $displayInfo = 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->captchaActivatedRequired = $captchaActivatedRequired; |
52 | $this->displayInfo = $displayInfo; |
53 | $this->ensureValid(); |
54 | } |
55 | |
56 | private function ensureValid() |
57 | { |
58 | if (!$this->testValid()) { |
59 | throw new InvalidArgumentException("The provided data is invalid according to the schema."); |
60 | } |
61 | } |
62 | |
63 | public function getProvider(): ?ThinnedProvider |
64 | { |
65 | return $this->provider; |
66 | } |
67 | |
68 | public function getShortName(): ?string |
69 | { |
70 | return $this->shortName; |
71 | } |
72 | |
73 | public function getEmailFrom(): ?string |
74 | { |
75 | return $this->emailFrom; |
76 | } |
77 | |
78 | public function getEmailRequired(): ?bool |
79 | { |
80 | return $this->emailRequired; |
81 | } |
82 | |
83 | public function getTelephoneActivated(): ?bool |
84 | { |
85 | return $this->telephoneActivated; |
86 | } |
87 | |
88 | public function getTelephoneRequired(): ?bool |
89 | { |
90 | return $this->telephoneRequired; |
91 | } |
92 | |
93 | public function getCustomTextfieldActivated(): ?bool |
94 | { |
95 | return $this->customTextfieldActivated; |
96 | } |
97 | |
98 | public function getCustomTextfieldRequired(): ?bool |
99 | { |
100 | return $this->customTextfieldRequired; |
101 | } |
102 | |
103 | public function getCustomTextfieldLabel(): ?string |
104 | { |
105 | return $this->customTextfieldLabel; |
106 | } |
107 | |
108 | public function getCaptchaActivatedRequired(): ?bool |
109 | { |
110 | return $this->captchaActivatedRequired; |
111 | } |
112 | |
113 | public function getDisplayInfo(): ?string |
114 | { |
115 | return $this->displayInfo; |
116 | } |
117 | |
118 | public function toArray(): array |
119 | { |
120 | return [ |
121 | 'id' => $this->id, |
122 | 'provider' => $this->provider, |
123 | 'shortName' => $this->shortName, |
124 | 'emailFrom' => $this->emailFrom, |
125 | 'emailRequired' => $this->emailRequired, |
126 | 'telephoneActivated' => $this->telephoneActivated, |
127 | 'telephoneRequired' => $this->telephoneRequired, |
128 | 'customTextfieldActivated' => $this->customTextfieldActivated, |
129 | 'customTextfieldRequired' => $this->customTextfieldRequired, |
130 | 'customTextfieldLabel' => $this->customTextfieldLabel, |
131 | 'captchaActivatedRequired' => $this->captchaActivatedRequired, |
132 | 'displayInfo' => $this->displayInfo, |
133 | ]; |
134 | } |
135 | |
136 | public function jsonSerialize(): mixed |
137 | { |
138 | return $this->toArray(); |
139 | } |
140 | } |