Subdivision   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 7
dl 0
loc 91
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getParent() 0 3 1
A getType() 0 3 1
A getCode() 0 3 1
A getLocalName() 0 10 2
A __construct() 0 10 1
1
<?php
2
3
namespace Sokil\IsoCodes\Database\Subdivisions;
4
5
use Sokil\IsoCodes\Database\Subdivisions;
6
7
class Subdivision
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 $code;
23
24
    /**
25
     * @var string
26
     */
27
    private $type;
28
29
    /**
30
     * @var string|null
31
     */
32
    private $parent;
33
34
    /**
35
     * Subdivision constructor.
36
     * @param string $name
37
     * @param string $code
38
     * @param string $type
39
     * @param string|null $parent
40
     */
41
    public function __construct(
42
        $name,
43
        $code,
44
        $type,
45
        $parent = null
46
    ) {
47
        $this->name = $name;
48
        $this->code = $code;
49
        $this->type = $type;
50
        $this->parent = $parent;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getName()
57
    {
58
        return $this->name;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getLocalName()
65
    {
66
        if ($this->localName === null) {
67
            $this->localName = dgettext(
68
                Subdivisions::getISONumber(),
69
                $this->name
70
            );
71
        }
72
73
        return $this->localName;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getCode()
80
    {
81
        return $this->code;
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function getType()
88
    {
89
        return $this->type;
90
    }
91
92
    /**
93
     * @return string|null
94
     */
95
    public function getParent()
96
    {
97
        return $this->parent;
98
    }
99
}
100