Total Complexity | 3 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | readonly class City |
||
8 | { |
||
9 | public function __construct( |
||
10 | public ?int $id, |
||
11 | public ?string $name, |
||
12 | public ?string $postCode |
||
13 | ) { |
||
14 | } |
||
15 | |||
16 | public static function fromArray(array $data = []): self |
||
17 | { |
||
18 | $id = $data['id'] ?? null; |
||
19 | $name = $data['name'] ?? null; |
||
20 | $postCode = $data['postCode'] ?? null; |
||
21 | |||
22 | return new self($id, $name, $postCode); |
||
23 | } |
||
24 | |||
25 | public function toArray(): array |
||
28 | } |
||
29 | } |
||
30 |