Point   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A addPoint() 0 12 3
A equals() 0 3 1
1
<?php
2
3
namespace Bmichotte\Dijkstra;
4
5
class Point
6
{
7
    public $x;
8
    public $y;
9
    public $points;
10
    public $ref;
11
12 12
    public function __construct(int $x, int $y)
13
    {
14 12
        $this->x = $x;
15 12
        $this->y = $y;
16 12
        $this->points = [];
17 12
        $this->ref = "{$x}-{$y}";
18 12
    }
19
20 6
    public function addPoint(self $point): self
21
    {
22 6
        if (! in_array($point, $this->points)) {
23 6
            $this->points[] = $point;
24
        }
25
26
        // add the reverse point
27 6
        if (! in_array($this, $point->points)) {
28 6
            $point->points[] = $this;
29
        }
30
31 6
        return $this;
32
    }
33
34 8
    public function equals(self $point): bool
35
    {
36 8
        return $this->ref === $point->ref;
37
    }
38
}
39