Total Complexity | 6 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class DomainLogic implements DomainLogicInterface |
||
8 | { |
||
9 | 6 | public function __construct(private Graph $graph) |
|
|
|||
10 | { |
||
11 | 6 | } |
|
12 | |||
13 | /** |
||
14 | * @param Coordinate $node |
||
15 | * @return Coordinate[] |
||
16 | */ |
||
17 | 3 | public function getAdjacentNodes(mixed $node): iterable |
|
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param Coordinate $node |
||
24 | * @param Coordinate $adjacent |
||
25 | * @return float|int |
||
26 | */ |
||
27 | 4 | public function calculateRealCost(mixed $node, mixed $adjacent): float | int |
|
28 | { |
||
29 | 4 | if (!$this->graph->hasLink($node, $adjacent)) { |
|
30 | 1 | throw new \DomainException('The provided nodes are not linked'); |
|
31 | } |
||
32 | |||
33 | 3 | return $this->graph->getLink($node, $adjacent)->getDistance(); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param Coordinate $fromNode |
||
38 | * @param Coordinate $toNode |
||
39 | * @return float|int |
||
40 | */ |
||
41 | 3 | public function calculateEstimatedCost(mixed $fromNode, mixed $toNode): float | int |
|
42 | { |
||
43 | 3 | return $this->euclideanDistance($fromNode, $toNode); |
|
44 | } |
||
45 | |||
46 | 3 | private function euclideanDistance(Coordinate $a, Coordinate $b): float |
|
52 | } |
||
53 | } |
||
54 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.