Language::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 6
nc 1
nop 6
1
<?php
2
3
namespace Sokil\IsoCodes\Database\Languages;
4
5
use Sokil\IsoCodes\Database\Languages;
6
7
class Language
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 $alpha3;
23
24
    /**
25
     * @var string
26
     */
27
    private $scope;
28
29
    /**
30
     * @var string
31
     */
32
    private $type;
33
34
    /**
35
     * @var string
36
     */
37
    private $invertedName;
38
39
    /**
40
     * @var string
41
     */
42
    private $alpha2;
43
44
    /**
45
     * @param string $name
46
     * @param string $alpha3
47
     * @param string $scope
48
     * @param string $type
49
     * @param string|null $invertedName
50
     * @param string|null $alpha2
51
     */
52
    public function __construct(
53
        $name,
54
        $alpha3,
55
        $scope,
56
        $type,
57
        $invertedName = null,
58
        $alpha2 = null
59
    ) {
60
        $this->name = $name;
61
        $this->alpha3 = $alpha3;
62
        $this->scope = $scope;
63
        $this->type = $type;
64
        $this->invertedName = $invertedName;
65
        $this->alpha2 = $alpha2;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getName()
72
    {
73
        return $this->name;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getLocalName()
80
    {
81
        if ($this->localName === null) {
82
            $this->localName = dgettext(
83
                Languages::getISONumber(),
84
                $this->name
85
            );
86
87
        }
88
89
        return $this->localName;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getAlpha3()
96
    {
97
        return $this->alpha3;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getScope()
104
    {
105
        return $this->scope;
106
    }
107
108
    /**
109
     * @return string
110
     */
111
    public function getType()
112
    {
113
        return $this->type;
114
    }
115
116
    /**
117
     * @return string|null
118
     */
119
    public function getInvertedName()
120
    {
121
        return $this->invertedName;
122
    }
123
124
    /**
125
     * @return string|null
126
     */
127
    public function getAlpha2()
128
    {
129
        return $this->alpha2;
130
    }
131
}
132