Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
92.50% covered (success)
92.50%
37 / 40
50.00% covered (danger)
50.00%
3 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
ThinnedProcess
92.50% covered (success)
92.50%
37 / 40
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%
17 / 17
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
18 / 18
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 int */
42    public int $serviceCount;
43/** @var string|null */
44    public ?string $status;
45
46    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, int $serviceCount = 0, ?string $status = null, ?string $captchaToken = null)
47    {
48        $this->processId = $processId;
49        $this->timestamp = $timestamp;
50        $this->authKey = $authKey;
51        $this->familyName = $familyName;
52        $this->customTextfield = $customTextfield;
53        $this->customTextfield2 = $customTextfield2;
54        $this->email = $email;
55        $this->telephone = $telephone;
56        $this->officeName = $officeName;
57        $this->officeId = $officeId;
58        $this->scope = $scope;
59        $this->subRequestCounts = $subRequestCounts;
60        $this->serviceId = $serviceId;
61        $this->serviceCount = $serviceCount;
62        $this->status = $status;
63        $this->captchaToken = $captchaToken;
64        $this->ensureValid();
65    }
66
67    /**
68     * Convert the ThinnedProcess object to an array.
69     *
70     * @return array
71     */
72    public function toArray(): array
73    {
74        return [
75            'processId' => $this->processId ?? null,
76            'timestamp' => $this->timestamp ?? null,
77            'authKey' => $this->authKey ?? null,
78            'familyName' => $this->familyName ?? null,
79            'customTextfield' => $this->customTextfield ?? null,
80            'customTextfield2' => $this->customTextfield2 ?? null,
81            'email' => $this->email ?? null,
82            'telephone' => $this->telephone ?? null,
83            'officeName' => $this->officeName ?? null,
84            'officeId' => $this->officeId ?? null,
85            'scope' => $this->scope ?? null,
86            'subRequestCounts' => $this->subRequestCounts,
87            'serviceId' => $this->serviceId ?? null,
88            'serviceCount' => $this->serviceCount,
89            'status' => $this->status ?? null,
90            'captchaToken' => $this->captchaToken ?? null,
91        ];
92    }
93
94    public function setCaptchaToken(string $token): void
95    {
96        $this->captchaToken = $token;
97    }
98
99    public function getCaptchaToken(): ?string
100    {
101        return $this->captchaToken;
102    }
103
104    private function ensureValid()
105    {
106        if (!$this->testValid()) {
107            throw new InvalidArgumentException("The provided data is invalid according to the schema.");
108        }
109    }
110
111    public function jsonSerialize(): mixed
112    {
113        return $this->toArray();
114    }
115}