Test Setup Failed
Push — main ( ab2c03...5e665b )
by Vasil
03:31
created

City::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VasilDakov\Econt\Model;
6
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
26
    {
27
        return get_object_vars($this);
28
    }
29
}
30