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

City   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 3 1
A fromArray() 0 7 1
A __construct() 0 5 1
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