Completed
Push — site-config ( 2b2097...bb0c13 )
by Arnaud
01:52
created

Language   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __toString() 0 4 1
A getName() 0 4 1
A getLocale() 0 4 1
A getWeight() 0 4 1
1
<?php
2
/*
3
 * Copyright (c) Arnaud Ligny <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Cecil\Config;
10
11
use Cecil\Config;
12
use Cecil\Exception\Exception;
13
14
/**
15
 * Class Language.
16
 */
17
class Language
18
{
19
    /**
20
     * Config.
21
     *
22
     * @var Config
23
     */
24
    protected $config;
25
26
    /**
27
     * Language constructor.
28
     *
29
     * @param Config
30
     */
31
    public function __construct($config)
32
    {
33
        $this->config = $config;
34
    }
35
36
    public function __toString()
37
    {
38
        return $this->config->getLanguageDefaultKey();
39
    }
40
41
    public function getName()
42
    {
43
        return $this->config->getLanguageProperty('name');
44
    }
45
46
    public function getLocale()
47
    {
48
        return $this->config->getLanguageProperty('locale');
49
    }
50
51
    public function getWeight()
52
    {
53
        return array_search($this->config->getLanguageDefaultKey(), array_keys($this->config->get('languages')));
54
    }
55
}
56