Completed
Push — Rover/albertg ( 3c48fc )
by Albert
01:56
created

Movement   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 86.67%

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromString() 0 4 1
A isForward() 0 4 1
A isBackward() 0 4 1
A isLeft() 0 4 1
A isRight() 0 4 1
A isTurn() 0 4 2
1
<?php
2
3
namespace Kata\Rover\Domain\Model;
4
5
class Movement
0 ignored issues
show
Coding Style introduced by
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
6
{
7
    private $movement;
8
9 2
    private function __construct(string $movement)
10
    {
11 2
        $this->movement = $movement;
12 2
    }
13
14 2
    public static function fromString($movement): Movement
15
    {
16 2
        return new self($movement);
17
    }
18
19 2
    public function isForward(): bool
20
    {
21 2
        return 'f' === $this->movement;
22
    }
23
24
    public function isBackward(): bool
25
    {
26
        return 'b' === $this->movement;
27
    }
28
29 2
    public function isLeft(): bool
30
    {
31 2
        return 'l' === $this->movement;
32
    }
33
34 2
    public function isRight(): bool
35
    {
36 2
        return 'r' === $this->movement;
37
    }
38
39 2
    public function isTurn(): bool
40
    {
41 2
        return $this->isLeft() || $this->isRight();
42
    }
43
}