Completed
Push — rover-kata ( c1a929...5eb0d1 )
by Marcos
02:12
created

Coordinates::equals()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php
2
3
namespace Kata\Rover;
4
5
final class Coordinates
6
{
7
    private $coordinate_x;
8
    private $coordinate_y;
9
10 13
    public function __construct(int $a_coordinate_x, int $a_coordinate_y)
11
    {
12 13
        $this->coordinate_x = $a_coordinate_x;
13 13
        $this->coordinate_y = $a_coordinate_y;
14 13
    }
15
16 13
    public function coordinateX(): int
17
    {
18 13
        return $this->coordinate_x;
19
    }
20
21 13
    public function coordinateY(): int
22
    {
23 13
        return $this->coordinate_y;
24
    }
25
26 7
    public function equals(Coordinates $coordinates): bool
27
    {
28 7
        if ($this->coordinate_x === $coordinates->coordinateX()
29 7
            && $this->coordinate_y === $coordinates->coordinateY()) {
30 2
            return true;
31
        }
32
33 6
        return false;
34
    }
35
}
36