Completed
Push — master ( 0eceaa...aee3a6 )
by Ben
15:21 queued 05:47
created

Locale::__construct()   A

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 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Thinktomorrow\Locale\Values;
4
5
final class Locale
6
{
7
    /**
8
     * @var string Locale key identifier
9
     */
10
    private $value;
11
12 78
    private function __construct(string $value)
13
    {
14 78
        $this->value = $value;
15 78
    }
16
17 78
    public static function from(string $value)
18
    {
19 78
        return new static($value);
20
    }
21
22 66
    public function get(): string
23
    {
24 66
        return $this->value;
25
    }
26
27 1
    public function equals(self $other): bool
28
    {
29 1
        return get_class($this) === get_class($other) && (string) $this === (string) $other;
30
    }
31
32 66
    public function __toString(): string
33
    {
34 66
        return $this->get();
35
    }
36
}
37