Link::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

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