Link::getSource()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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