Lines
0.00%
0 / 26
Functions and Methods
0.00%
0 / 5
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Requeststatistic | 0.00% | 0 / 26 | 0.00% | 0 / 5 | 156 | 0.00% | 0 / 1 | |||
| getScopeRequests | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| getAdditionalDepartmentRequests | 0.00% | 0 / 2 | 0.00% | 0 / 1 | 6 | |||||
| getDefaults | 0.00% | 0 / 4 | 0.00% | 0 / 1 | 2 | |||||
| addData | 0.00% | 0 / 8 | 0.00% | 0 / 1 | 30 | |||||
| jsonSerialize | 0.00% | 0 / 10 | 0.00% | 0 / 1 | 6 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace BO\Zmsentities; | |
| 6 | ||
| 7 | /** | |
| 8 | * @property Collection\RequestList $scopeRequests | |
| 9 | * @property Collection\RequestList $additionalDepartmentRequests | |
| 10 | */ | |
| 11 | class Requeststatistic extends Schema\Entity implements Helper\NoSanitize | |
| 12 | { | |
| 13 | public static $schema = 'requeststatistic.json'; | |
| 14 | ||
| 15 | public function getScopeRequests(): Collection\RequestList | |
| 16 | { | |
| 17 | $value = $this['scopeRequests'] ?? null; | |
| 18 | return $value instanceof Collection\RequestList ? $value : new Collection\RequestList(); | |
| 19 | } | |
| 20 | ||
| 21 | public function getAdditionalDepartmentRequests(): Collection\RequestList | |
| 22 | { | |
| 23 | $value = $this['additionalDepartmentRequests'] ?? null; | |
| 24 | return $value instanceof Collection\RequestList ? $value : new Collection\RequestList(); | |
| 25 | } | |
| 26 | ||
| 27 | #[\Override] | |
| 28 | public function getDefaults(): array | |
| 29 | { | |
| 30 | return [ | |
| 31 | 'scopeRequests' => new Collection\RequestList(), | |
| 32 | 'additionalDepartmentRequests' => new Collection\RequestList(), | |
| 33 | ]; | |
| 34 | } | |
| 35 | ||
| 36 | /** | |
| 37 | * @param array|object $mergeData | |
| 38 | */ | |
| 39 | #[\Override] | |
| 40 | public function addData($mergeData): static | |
| 41 | { | |
| 42 | if (isset($mergeData['scopeRequests']) && !$mergeData['scopeRequests'] instanceof Collection\RequestList) { | |
| 43 | $mergeData['scopeRequests'] = (new Collection\RequestList())->addData($mergeData['scopeRequests']); | |
| 44 | } | |
| 45 | if ( | |
| 46 | isset($mergeData['additionalDepartmentRequests']) | |
| 47 | && !$mergeData['additionalDepartmentRequests'] instanceof Collection\RequestList | |
| 48 | ) { | |
| 49 | $mergeData['additionalDepartmentRequests'] = (new Collection\RequestList()) | |
| 50 | ->addData($mergeData['additionalDepartmentRequests']); | |
| 51 | } | |
| 52 | ||
| 53 | parent::addData($mergeData); | |
| 54 | return $this; | |
| 55 | } | |
| 56 | ||
| 57 | #[\Override] | |
| 58 | public function jsonSerialize(): mixed | |
| 59 | { | |
| 60 | $serialized = parent::jsonSerialize(); | |
| 61 | $scopeRequests = array_values($this->getScopeRequests()->getArrayCopy()); | |
| 62 | $additionalDepartmentRequests = array_values($this->getAdditionalDepartmentRequests()->getArrayCopy()); | |
| 63 | ||
| 64 | if (is_array($serialized)) { | |
| 65 | $serialized['scopeRequests'] = $scopeRequests; | |
| 66 | $serialized['additionalDepartmentRequests'] = $additionalDepartmentRequests; | |
| 67 | return $serialized; | |
| 68 | } | |
| 69 | ||
| 70 | $serialized->scopeRequests = $scopeRequests; | |
| 71 | $serialized->additionalDepartmentRequests = $additionalDepartmentRequests; | |
| 72 | return $serialized; | |
| 73 | } | |
| 74 | } |