Passed
Pull Request — master (#199)
by
unknown
02:28
created

LocaleState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 7
c 1
b 0
f 1
dl 0
loc 35
ccs 7
cts 9
cp 0.7778
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setLanguage() 0 4 1
A __toString() 0 3 1
A __construct() 0 3 1
A getLanguage() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\State;
6
7
final class LocaleState
8
{
9
    private string $language;
10
11 122
    public function __construct(string $language = 'en')
12
    {
13 122
        $this->language = $language;
14
    }
15
16
    /**
17
     * Set the specified language code.
18
     *
19
     * @param string $language The language code.
20
     *
21
     * @return static
22
     */
23 2
    public function setLanguage(string $language): self
24
    {
25 2
        $this->language = $language;
26 2
        return $this;
27
    }
28
29
    /**
30
     * Gets the language code.
31
     *
32
     * @return string The language code.
33
     */
34 61
    public function getLanguage(): string
35
    {
36 61
        return $this->language;
37
    }
38
39
    public function __toString(): string
40
    {
41
        return $this->getLanguage();
42
    }
43
}
44