LocaleState::setLocale()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 130
    public function __construct(
15
        private string $locale = 'en'
16
    ) {
17 130
    }
18
19
    /**
20
     * Set the specified locale code.
21
     *
22
     * @param string $locale The locale code.
23
     */
24 3
    public function setLocale(string $locale): self
25
    {
26 3
        $this->locale = $locale;
27 3
        return $this;
28
    }
29
30
    /**
31
     * Gets the locale code.
32
     *
33
     * @return string The locale code.
34
     */
35 66
    public function getLocale(): string
36
    {
37 66
        return $this->locale;
38
    }
39
40
    public function __toString(): string
41
    {
42
        return $this->getLocale();
43
    }
44
}
45