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

Obstacle::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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
}