Locale   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 72
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A __get() 0 4 1
A __isset() 0 4 1
1
<?php
2
3
namespace RichanFongdasen\I18n;
4
5
class Locale
6
{
7
    /**
8
     * Country code.
9
     *
10
     * @var string
11
     */
12
    protected $country;
13
14
    /**
15
     * IETF Code.
16
     *
17
     * @var string
18
     */
19
    protected $ietfCode;
20
21
    /**
22
     * Language code.
23
     *
24
     * @var string
25
     */
26
    protected $language;
27
28
    /**
29
     * Locale name.
30
     *
31
     * @var string
32
     */
33
    protected $name;
34
35
    /**
36
     * Class constructor.
37
     *
38
     * @param string $name
39
     * @param string $language
40
     * @param string $country
41
     */
42
    public function __construct($name, $language, $country)
43
    {
44
        $this->country = strtoupper($country);
45
        $this->language = strtolower($language);
46
        $this->name = $name;
47
48
        $this->ietfCode = $this->language.'-'.$this->country;
49
    }
50
51
    /**
52
     * Magic method to read data from inaccessible
53
     * properties.
54
     *
55
     * @param string $name
56
     *
57
     * @return string
58
     */
59
    public function __get(string $name): string
60
    {
61
        return $this->{$name};
62
    }
63
64
    /**
65
     * Magic method to determine if a variable is set
66
     * and is not NULL.
67
     *
68
     * @param string $name
69
     *
70
     * @return bool
71
     */
72
    public function __isset(string $name): bool
73
    {
74
        return isset($this->{$name});
75
    }
76
}
77