GeometricView::neighboursOf()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Pathfinder\Graph;
4
5
use Stratadox\Pathfinder\Environment;
6
use Stratadox\Pathfinder\Network;
7
use Stratadox\Pathfinder\Labels;
8
use Stratadox\Pathfinder\Position;
9
10
final class GeometricView implements Environment
11
{
12
    private $actualGraph;
13
14
    private function __construct(Network $actualGraph)
15
    {
16
        $this->actualGraph = $actualGraph;
17
    }
18
19
    public static function of(Network $actualGraph): Environment
20
    {
21
        if ($actualGraph instanceof Environment) {
22
            return $actualGraph;
23
        }
24
        return new self($actualGraph);
25
    }
26
27
    public function all(): Labels
28
    {
29
        return $this->actualGraph->all();
30
    }
31
32
    public function positionOf(string $node): Position
33
    {
34
        return At::position();
35
    }
36
37
    public function neighboursOf(string $node): Labels
38
    {
39
        return $this->actualGraph->neighboursOf($node);
40
    }
41
42
    public function areNeighbours(string $source, string $neighbour): bool
43
    {
44
        return $this->actualGraph->areNeighbours($source, $neighbour);
45
    }
46
47
    public function has(string $node): bool
48
    {
49
        return $this->actualGraph->has($node);
50
    }
51
52
    public function movementCostBetween(string $source, string $neighbour): float
53
    {
54
        return $this->actualGraph->movementCostBetween($source, $neighbour);
55
    }
56
57
    public function hasNegativeEdgeCosts(): bool
58
    {
59
        return $this->actualGraph->hasNegativeEdgeCosts();
60
    }
61
}
62