Link   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 12
c 0
b 0
f 0
dl 0
loc 30
ccs 13
cts 13
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getDestination() 0 3 1
A getDistance() 0 3 1
A getSource() 0 3 1
1
<?php
2
3
namespace JMGQ\AStar\Example\Graph;
4
5
class Link
6
{
7
    private Coordinate $source;
8
    private Coordinate $destination;
9
    private float $distance;
10
11 22
    public function __construct(Coordinate $source, Coordinate $destination, float $distance)
12
    {
13 22
        if ($distance < 0) {
14 2
            throw new \InvalidArgumentException("Invalid distance: $distance");
15
        }
16
17 20
        $this->source = $source;
18 20
        $this->destination = $destination;
19 20
        $this->distance = $distance;
20 20
    }
21
22 20
    public function getSource(): Coordinate
23
    {
24 20
        return $this->source;
25
    }
26
27 20
    public function getDestination(): Coordinate
28
    {
29 20
        return $this->destination;
30
    }
31
32 13
    public function getDistance(): float
33
    {
34 13
        return $this->distance;
35
    }
36
}
37