Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
93.18% covered (success)
93.18%
41 / 44
50.00% covered (danger)
50.00%
3 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ThinnedProcess
93.18% covered (success)
93.18%
41 / 44
50.00% covered (danger)
50.00%
3 / 6
7.02
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
19 / 19
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
20 / 20
100.00% covered (success)
100.00%
1 / 1
1
 setCaptchaToken
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCaptchaToken
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 ensureValid
50.00% covered (danger)
50.00%
1 / 2
0.00% covered (danger)
0.00%
0 / 1
2.50
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace BO\Zmscitizenapi\Models;
6
7use BO\Zmscitizenapi\Models\ThinnedScope;
8use BO\Zmsentities\Schema\Entity;
9use InvalidArgumentException;
10use JsonSerializable;
11
12class 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 $customTextfield2;
27/** @var string|null */
28    public ?string $email;
29/** @var string|null */
30    public ?string $telephone;
31/** @var string|null */
32    public ?string $officeName;
33/** @var int|null */
34    public ?int $officeId;
35/** @var ThinnedScope|null */
36    public ?ThinnedScope $scope;
37/** @var array */
38    public array $subRequestCounts;
39/** @var int|null */
40    public ?int $serviceId;
41/** @var string|null */
42    public ?string $serviceName;
43/** @var int */
44    public int $serviceCount;
45/** @var string|null */
46    public ?string $status;
47/** @var string|null */
48    public ?string $captchaToken;
49/** @var int|null */
50    public ?int $slotCount;
51
52    public function __construct(?int $processId = null, ?string $timestamp = null, ?string $authKey = null, ?string $familyName = null, ?string $customTextfield = null, ?string $customTextfield2 = null, ?string $email = null, ?string $telephone = null, ?string $officeName = null, ?int $officeId = null, ?ThinnedScope $scope = null, array $subRequestCounts = [], ?int $serviceId = null, ?string $serviceName = null, int $serviceCount = 0, ?string $status = null, ?string $captchaToken = null, ?int $slotCount = null)
53    {
54        $this->processId = $processId;
55        $this->timestamp = $timestamp;
56        $this->authKey = $authKey;
57        $this->familyName = $familyName;
58        $this->customTextfield = $customTextfield;
59        $this->customTextfield2 = $customTextfield2;
60        $this->email = $email;
61        $this->telephone = $telephone;
62        $this->officeName = $officeName;
63        $this->officeId = $officeId;
64        $this->scope = $scope;
65        $this->subRequestCounts = $subRequestCounts;
66        $this->serviceId = $serviceId;
67        $this->serviceName = $serviceName;
68        $this->serviceCount = $serviceCount;
69        $this->status = $status;
70        $this->captchaToken = $captchaToken;
71        $this->slotCount = $slotCount;
72        $this->ensureValid();
73    }
74
75    /**
76     * Convert the ThinnedProcess object to an array.
77     *
78     * @return array
79     */
80    public function toArray(): array
81    {
82        return [
83            'processId' => $this->processId ?? null,
84            'timestamp' => $this->timestamp ?? null,
85            'authKey' => $this->authKey ?? null,
86            'familyName' => $this->familyName ?? null,
87            'customTextfield' => $this->customTextfield ?? null,
88            'customTextfield2' => $this->customTextfield2 ?? null,
89            'email' => $this->email ?? null,
90            'telephone' => $this->telephone ?? null,
91            'officeName' => $this->officeName ?? null,
92            'officeId' => $this->officeId ?? null,
93            'scope' => $this->scope ?? null,
94            'subRequestCounts' => $this->subRequestCounts,
95            'serviceId' => $this->serviceId ?? null,
96            'serviceName' => $this->serviceName ?? null,
97            'serviceCount' => $this->serviceCount,
98            'status' => $this->status ?? null,
99            'captchaToken' => $this->captchaToken ?? null,
100            'slotCount' => $this->slotCount ?? null
101        ];
102    }
103
104    public function setCaptchaToken(string $token): void
105    {
106        $this->captchaToken = $token;
107    }
108
109    public function getCaptchaToken(): ?string
110    {
111        return $this->captchaToken;
112    }
113
114    private function ensureValid()
115    {
116        if (!$this->testValid()) {
117            throw new InvalidArgumentException("The provided data is invalid according to the schema.");
118        }
119    }
120
121    public function jsonSerialize(): mixed
122    {
123        return $this->toArray();
124    }
125}