Passed
Branch 2.0 (72e182)
by Philippe
02:18
created

Locale::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
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 98
    private function __construct(string $value)
13
    {
14 98
        $this->value = $value;
15 98
    }
16
17 98
    public static function from(string $value)
18
    {
19 98
        return new static($value);
20
    }
21
22 44
    public function get(): string
23
    {
24 44
        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 21
    public function __toString(): string
33
    {
34 21
        return $this->get();
35
    }
36
37
38
}