Passed
Pull Request — master (#199)
by Sergei
04:29 queued 02:11
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 __toString() 0 3 1
A __construct() 0 3 1
A setLocale() 0 4 1
A getLocale() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\State;
6
7
/**
8
 * @internal
9
 */
10
final class LocaleState
11
{
12
    private string $locale;
13
14 122
    public function __construct(string $locale = 'en')
15
    {
16 122
        $this->locale = $locale;
17
    }
18
19
    /**
20
     * Set the specified locale code.
21
     *
22
     * @param string $locale The locale code.
23
     *
24
     * @return static
25
     */
26 2
    public function setLocale(string $locale): self
27
    {
28 2
        $this->locale = $locale;
29 2
        return $this;
30
    }
31
32
    /**
33
     * Gets the locale code.
34
     *
35
     * @return string The locale code.
36
     */
37 61
    public function getLocale(): string
38
    {
39 61
        return $this->locale;
40
    }
41
42
    public function __toString(): string
43
    {
44
        return $this->getLocale();
45
    }
46
}
47