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

Direction   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A north() 0 4 1
A south() 0 4 1
A east() 0 4 1
A west() 0 4 1
A direction() 0 4 1
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