Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
94.12% |
32 / 34 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
ThinnedProcess | |
94.12% |
32 / 34 |
|
50.00% |
2 / 4 |
5.01 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
15 / 15 |
|
100.00% |
1 / 1 |
1 | |||
toArray | |
100.00% |
16 / 16 |
|
100.00% |
1 / 1 |
1 | |||
ensureValid | |
50.00% |
1 / 2 |
|
0.00% |
0 / 1 |
2.50 | |||
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\Zmscitizenapi\Models\ThinnedScope; |
8 | use BO\Zmsentities\Schema\Entity; |
9 | use InvalidArgumentException; |
10 | use JsonSerializable; |
11 | |
12 | class ThinnedProcess extends Entity implements JsonSerializable |
13 | { |
14 | public static $schema = "citizenapi/thinnedProcess.json"; |
15 | /** @var int|null */ |
16 | public ?int $processId; |
17 | /** @var string|null */ |
18 | public ?string $timestamp; |
19 | /** @var string|null */ |
20 | public ?string $authKey; |
21 | /** @var string|null */ |
22 | public ?string $familyName; |
23 | /** @var string|null */ |
24 | public ?string $customTextfield; |
25 | /** @var string|null */ |
26 | public ?string $email; |
27 | /** @var string|null */ |
28 | public ?string $telephone; |
29 | /** @var string|null */ |
30 | public ?string $officeName; |
31 | /** @var int|null */ |
32 | public ?int $officeId; |
33 | /** @var ThinnedScope|null */ |
34 | public ?ThinnedScope $scope; |
35 | /** @var array */ |
36 | public array $subRequestCounts; |
37 | /** @var int|null */ |
38 | public ?int $serviceId; |
39 | /** @var int */ |
40 | public int $serviceCount; |
41 | /** @var string|null */ |
42 | public ?string $status; |
43 | public function __construct(?int $processId = null, ?string $timestamp = null, ?string $authKey = null, ?string $familyName = null, ?string $customTextfield = null, ?string $email = null, ?string $telephone = null, ?string $officeName = null, ?int $officeId = null, ?ThinnedScope $scope = null, array $subRequestCounts = [], ?int $serviceId = null, int $serviceCount = 0, ?string $status = null) |
44 | { |
45 | $this->processId = $processId; |
46 | $this->timestamp = $timestamp; |
47 | $this->authKey = $authKey; |
48 | $this->familyName = $familyName; |
49 | $this->customTextfield = $customTextfield; |
50 | $this->email = $email; |
51 | $this->telephone = $telephone; |
52 | $this->officeName = $officeName; |
53 | $this->officeId = $officeId; |
54 | $this->scope = $scope; |
55 | $this->subRequestCounts = $subRequestCounts; |
56 | $this->serviceId = $serviceId; |
57 | $this->serviceCount = $serviceCount; |
58 | $this->status = $status; |
59 | $this->ensureValid(); |
60 | } |
61 | |
62 | /** |
63 | * Convert the ThinnedProcess object to an array. |
64 | * |
65 | * @return array |
66 | */ |
67 | public function toArray(): array |
68 | { |
69 | return [ |
70 | 'processId' => $this->processId ?? null, |
71 | 'timestamp' => $this->timestamp ?? null, |
72 | 'authKey' => $this->authKey ?? null, |
73 | 'familyName' => $this->familyName ?? null, |
74 | 'customTextfield' => $this->customTextfield ?? null, |
75 | 'email' => $this->email ?? null, |
76 | 'telephone' => $this->telephone ?? null, |
77 | 'officeName' => $this->officeName ?? null, |
78 | 'officeId' => $this->officeId ?? null, |
79 | 'scope' => $this->scope ?? null, |
80 | 'subRequestCounts' => $this->subRequestCounts, |
81 | 'serviceId' => $this->serviceId ?? null, |
82 | 'serviceCount' => $this->serviceCount, |
83 | 'status' => $this->status ?? null, |
84 | ]; |
85 | } |
86 | |
87 | private function ensureValid() |
88 | { |
89 | if (!$this->testValid()) { |
90 | throw new InvalidArgumentException("The provided data is invalid according to the schema."); |
91 | } |
92 | } |
93 | |
94 | public function jsonSerialize(): mixed |
95 | { |
96 | return $this->toArray(); |
97 | } |
98 | } |