GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( a1835d...10e84a )
by
unknown
02:48
created

Language::getProperties()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Framework\DataStructures;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\DataStructures\SplArrayObject;
19
use O2System\Spl\Info\SplDirectoryInfo;
20
21
/**
22
 * Class Language
23
 *
24
 * @package O2System\Framework\DataStructures
25
 */
26
class Language extends SplDirectoryInfo
27
{
28
    /**
29
     * Language Properties
30
     *
31
     * @var array
32
     */
33
    private $properties = [];
34
35
    // ------------------------------------------------------------------------
36
37
    /**
38
     * Language::__construct
39
     *
40
     * @param string $dir
41
     */
42
    public function __construct($dir)
43
    {
44
        parent::__construct($dir);
45
46
        // Set Properties
47
        if (is_file($propertiesFilePath = $dir . DIRECTORY_SEPARATOR . 'language.json')) {
48
            $properties = json_decode(file_get_contents($propertiesFilePath), true);
49
50
            if (json_last_error() === JSON_ERROR_NONE) {
51
                $this->properties = $properties;
52
            }
53
        }
54
    }
55
56
    // ------------------------------------------------------------------------
57
58
    /**
59
     * Language::isValid
60
     *
61
     * @return bool
62
     */
63
    public function isValid()
64
    {
65
        if (count($this->properties)) {
66
            return true;
67
        }
68
69
        return false;
70
    }
71
72
    // ------------------------------------------------------------------------
73
74
    /**
75
     * Language::getCode
76
     *
77
     * @return string
78
     */
79
    public function getCode()
80
    {
81
        return strtoupper(substr(md5($this->getDirName()), 2, 7));
82
    }
83
84
    // ------------------------------------------------------------------------
85
86
    /**
87
     * Language::getChecksum
88
     *
89
     * @return string
90
     */
91
    public function getChecksum()
92
    {
93
        return md5($this->getMTime());
94
    }
95
96
    // ------------------------------------------------------------------------
97
98
    /**
99
     * Language::getProperties
100
     *
101
     * @return \O2System\Spl\DataStructures\SplArrayObject
102
     */
103
    public function getProperties()
104
    {
105
        return new SplArrayObject($this->properties);
106
    }
107
108
    // ------------------------------------------------------------------------
109
110
    /**
111
     * Language::getLocale
112
     *
113
     * @return mixed
114
     */
115
    public function getLocale()
116
    {
117
        $parts = explode('-', $this->getParameter());
118
119
        return reset($parts);
120
    }
121
122
    // ------------------------------------------------------------------------
123
124
    /**
125
     * Language::getParameter
126
     *
127
     * @return string
128
     */
129
    public function getParameter()
130
    {
131
        return $this->getDirName();
132
    }
133
134
    // ------------------------------------------------------------------------
135
136
    /**
137
     * Language::getIdeom
138
     *
139
     * @return mixed
140
     */
141
    public function getIdeom()
142
    {
143
        $parts = explode('-', $this->getParameter());
144
145
        return end($parts);
146
    }
147
}