Completed
Push — rover-kata ( dafa5a...db70b6 )
by Marcos
15:30 queued 44s
created

Direction::direction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Kata\Rover;
4
5
final class Direction
6
{
7
    public const NORTH = 'n';
8
    public const SOUTH = 's';
9
    public const EAST = 'e';
10
    public const WEST = 'w';
11
12
    private $direction;
13
14
    private function __construct(string $direction)
15
    {
16
        $this->direction = $direction;
17
    }
18
19
    public static function north(): Direction
20
    {
21
        return new self(Direction::NORTH);
22
    }
23
24
    public static function south(): Direction
25
    {
26
        return new self(Direction::SOUTH);
27
    }
28
29
    public static function east(): Direction
30
    {
31
        return new self(Direction::EAST);
32
    }
33
34
    public static function west(): Direction
35
    {
36
        return new self(Direction::WEST);
37
    }
38
39
    public function direction(): Direction
40
    {
41
        return $this->direction;
42
    }
43
}
44