Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class DynamicModel implements \JsonSerializable |
||
7 | { |
||
8 | |||
9 | public function __construct(public int $id, public string $name, public string $value, public null|Collection $items) |
||
10 | { |
||
11 | } |
||
12 | |||
13 | |||
14 | /** |
||
15 | * toArray |
||
16 | * @return array<string,null|string>> |
||
17 | */ |
||
18 | public function toArray(): array |
||
19 | { |
||
20 | $data = [ |
||
21 | 'id' => $this->id ?? 0, |
||
22 | 'name' => $this->name ?? null, |
||
23 | 'value' => $this->value ?? null, |
||
24 | 'items' => $this->items ? $this->items->toArray() : null |
||
25 | ]; |
||
26 | |||
27 | return $data; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * jsonSerialize |
||
32 | * @return mixed |
||
33 | */ |
||
34 | public function jsonSerialize() |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * __toString |
||
41 | * @return string |
||
42 | */ |
||
43 | public function __toString(): string |
||
46 | } |
||
47 | } |