GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#62)
by Simone
05:12 queued 02:05
created

DijkstraWalker::getPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Mado\QueryBundle\Component\Meta;
4
5
/**
6
 * @since Class available since Release 2.1.0
7
 */
8
final class DijkstraWalker
9
{
10
    private $builder;
11
12
    private $dijkstra;
13
14
    private $path;
15
16
    public function __construct(
17
        DataMapper $builder,
18
        Dijkstra $dijkstra
19
    ) {
20
        $this->builder = $builder;
21
        $this->dijkstra = $dijkstra;
22
    }
23
24
    public function buildPathBetween($start, $end) : bool
25
    {
26
        $this->builder->rebuildRelationMap();
27
28
        $map = $this->builder->getMap();
29
30
        $this->builder->setMap($map);
31
32
        $percorso = $tutta = $this->dijkstra->shortestPaths($start, $end);
0 ignored issues
show
Unused Code introduced by
The assignment to $tutta is dead and can be removed.
Loading history...
33
        $prevRelations = $map[$start]['relations'];
34
35
        $this->path = '_embedded';
36
37
        foreach ($percorso[0] as $nodo => $meta) {
38
            if ($relationName = array_search($meta, $prevRelations)) {
39
                $this->path .= '.' . $relationName;
40
            }
41
42
            $prevRelations = $map[$meta]['relations'];
43
        }
44
45
        return true;
46
    }
47
48
    public function getPath() : string
49
    {
50
        if (!$this->path) {
51
            throw new \RuntimeException(
52
                'Oops! path was never builded.'
53
            );
54
        }
55
56
        return $this->path;
57
    }
58
}
59