Passed
Push — main ( 75dae7...ab2c03 )
by Vasil
03:11
created

Country   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
c 1
b 0
f 0
dl 0
loc 26
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A fromArray() 0 5 1
1
<?php
2
3
namespace VasilDakov\Econt\Model;
4
5
final class Country
6
{
7
    /*
8
    id	int	[0..1]
9
    code2	string	[0..1] ISO 3166-1 alpha-2 code (e.g. BG, GB, GR)
10
    code3	string	[0..1] ISO 3166-1 alpha-3 code (e.g. BGR ,GBR, GRC)
11
    name	string	[0..1] The bulgarian name of the country
12
    nameEn	string	[0..1] The international name of the country
13
    isEU	boolean	[0..1] True if country is a member of the EU
14
    */
15
16 4
    public function __construct(
17
        public readonly ?int $id,
18
        public readonly ?string $code2,
19
        public readonly ?string $code3,
20
        public readonly ?string $name,
21
        public readonly ?string $nameEn,
22
        public readonly ?bool $isEU
23
    ) {
24 4
    }
25
26 4
    public static function fromArray(array $data): Country
27
    {
28 4
        list($id, $code2, $code3, $name, $nameEn, $isEU) = array_values($data);
29
30 4
        return new Country($id, $code2, $code3, $name, $nameEn, $isEU);
31
    }
32
}
33