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

Language   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 39
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getLang() 0 4 1
A getTranslation() 0 4 2
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
}