Completed
Push — master ( 0de0cb...fee715 )
by
unknown
01:48
created

Language::getLang()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PluginSimpleValidate\Libraries;
4
5
class Language
6
{
7
    /**
8
     * @var string
9
     */
10
    private $lang;
11
12
    /**
13
     * @var array
14
     */
15
    private $translation;
16
17
    /**
18
     * Language constructor.
19
     * @param string $lang
20
     */
21 4
    public function __construct(string $lang)
22
    {
23 4
        $this->lang = $lang;
24 4
        $this->translation = include implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), '..', 'lang', $this->lang . '.php']);
25 4
    }
26
27
    /**
28
     * @return string
29
     */
30
    public function getLang(): string
31
    {
32
        return $this->lang;
33
    }
34
35
    /**
36
     * @param string $key
37
     * @return string
38
     */
39 3
    public function getTranslation(string $key)
40
    {
41 3
        return isset($this->translation[$key]) ? $this->translation[$key] : $key;
42
    }
43
}