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

Obstacle   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 26
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 6 1
A position() 0 4 1
A collide() 0 4 1
1
<?php
2
3
namespace Kata\Rover\Domain\Model;
4
5
class Obstacle
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 $position;
8
9 2
    private function __construct(Position $a_position)
10
    {
11 2
        $this->position = $a_position;
12 2
    }
13
14 2
    public static function create(int $a_col, int $a_row): Obstacle
15
    {
16 2
        $position = Position::create($a_col, $a_row);
17
18 2
        return new Obstacle($position);
19
    }
20
21
    public function position(): Position
22
    {
23
        return $this->position;
24
    }
25
26 2
    public function collide(Position $a_position): bool
27
    {
28 2
        return $this->position->equals($a_position);
29
    }
30
}