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

Locale   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A from() 0 4 1
A get() 0 4 1
A equals() 0 4 2
A __toString() 0 4 1
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
}