Completed
Push — rover-kata ( db70b6...cc14c5 )
by Marcos
18:19 queued 11:27
created

Direction   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 39
ccs 13
cts 13
cp 1
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 1
    private function __construct(string $direction)
15
    {
16 1
        $this->direction = $direction;
17 1
    }
18
19 1
    public static function north(): Direction
20
    {
21 1
        return new self(Direction::NORTH);
22
    }
23
24 1
    public static function south(): Direction
25
    {
26 1
        return new self(Direction::SOUTH);
27
    }
28
29 1
    public static function east(): Direction
30
    {
31 1
        return new self(Direction::EAST);
32
    }
33
34 1
    public static function west(): Direction
35
    {
36 1
        return new self(Direction::WEST);
37
    }
38
39 1
    public function direction(): string
40
    {
41 1
        return $this->direction;
42
    }
43
}
44