Passed
Pull Request — master (#211)
by Alexander
05:07 queued 02:35
created

LocaleState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 1
b 0
f 0
dl 0
loc 31
ccs 6
cts 8
cp 0.75
rs 10

4 Methods

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