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

Coordinates   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
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 31
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A coordinateX() 0 4 1
A coordinateY() 0 4 1
A equals() 0 9 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