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.

DijkstraWalker::buildPathBetween()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 18
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 9.9666
cc 3
nc 3
nop 2
crap 3
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 implements
9
    GraphWalker
10
{
11
    private $builder;
12
13
    private $dijkstra;
14
15
    private $path;
16
17
    private $map;
18
19 2
    public function __construct(
20
        DataMapper $builder,
21
        Dijkstra $dijkstra
22
    ) {
23 2
        $this->builder = $builder;
24 2
        $this->dijkstra = $dijkstra;
25
26 2
        $this->init();
27 2
    }
28
29 1
    public function buildPathBetween($start, $end) : bool
30
    {
31 1
        $this->builder->rebuildRelationMap();
32
33 1
        $shortestPath = $this->dijkstra->shortestPaths($start, $end);
34 1
        $prevRelations = $this->map[$start]['relations'];
35
36 1
        $this->path = '_embedded';
37
38 1
        foreach ($shortestPath[0] as $meta) {
39 1
            if ($relationName = array_search($meta, $prevRelations)) {
40 1
                $this->path .= '.' . $relationName;
41
            }
42
43 1
            $prevRelations = $this->map[$meta]['relations'];
44
        }
45
46 1
        return true;
47
    }
48
49 2
    public function getPath() : string
50
    {
51 2
        if (!$this->path) {
52 1
            throw new \RuntimeException(
53 1
                'Oops! path was never builded.'
54
            );
55
        }
56
57 1
        return $this->path;
58
    }
59
60 2
    public function init()
61
    {
62 2
        $this->dijkstra->setMap(
63 2
            $this->map = $this->builder->getMap()
64
        );
65 2
    }
66
}
67