Country   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 107
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getOfficialName() 0 3 1
A getAlpha3() 0 3 1
A getName() 0 3 1
A getAlpha2() 0 3 1
A getNumericCode() 0 3 1
A getLocalName() 0 10 2
1
<?php
2
3
namespace Sokil\IsoCodes\Database\Countries;
4
5
use Sokil\IsoCodes\Database\Countries;
6
7
class Country
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var string
16
     */
17
    private $localName;
18
19
    /**
20
     * @var string
21
     */
22
    private $alpha2;
23
24
    /**
25
     * @var string
26
     */
27
    private $alpha3;
28
29
    /**
30
     * @var string
31
     */
32
    private $numericCode;
33
34
    /**
35
     * @var string
36
     */
37
    private $officialName;
38
39
    /**
40
     * Country constructor.
41
     * @param string $name
42
     * @param string $alpha2
43
     * @param string $alpha3
44
     * @param int $numericCode
45
     * @param string|null $officialName
46
     */
47
    public function __construct(
48
        $name,
49
        $alpha2,
50
        $alpha3,
51
        $numericCode,
52
        $officialName = null
53
    ) {
54
        $this->name = $name;
55
        $this->alpha2 = $alpha2;
56
        $this->alpha3 = $alpha3;
57
        $this->numericCode = $numericCode;
58
        $this->officialName = $officialName;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getAlpha2()
65
    {
66
        return $this->alpha2;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getAlpha3()
73
    {
74
        return $this->alpha3;
75
    }
76
77
    /**
78
     * @return int
79
     */
80
    public function getNumericCode()
81
    {
82
        return $this->numericCode;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->numericCode returns the type string which is incompatible with the documented return type integer.
Loading history...
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getName()
89
    {
90
        return $this->name;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getLocalName()
97
    {
98
        if ($this->localName === null) {
99
            $this->localName = dgettext(
100
                Countries::getISONumber(),
101
                $this->name
102
            );
103
        }
104
105
        return $this->localName;
106
    }
107
108
    /**
109
     * @return string|null
110
     */
111
    public function getOfficialName()
112
    {
113
        return $this->officialName;
114
    }
115
}
116