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
04:00 queued 01:32
created

DijkstraWalker::buildPathBetween()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 18
rs 9.4285
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
    private $map;
17
18
    public function __construct(
19
        DataMapper $builder,
20
        Dijkstra $dijkstra
21
    ) {
22
        $this->builder = $builder;
23
        $this->dijkstra = $dijkstra;
24
25
        $this->init();
26
    }
27
28
    public function buildPathBetween($start, $end) : bool
29
    {
30
        $this->builder->rebuildRelationMap();
31
32
        $shortestPath = $this->dijkstra->shortestPaths($start, $end);
33
        $prevRelations = $this->map[$start]['relations'];
34
35
        $this->path = '_embedded';
36
37
        foreach ($shortestPath[0] as $meta) {
38
            if ($relationName = array_search($meta, $prevRelations)) {
39
                $this->path .= '.' . $relationName;
40
            }
41
42
            $prevRelations = $this->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
    public function init()
60
    {
61
        $this->dijkstra->setMap(
62
            $this->map = $this->builder->getMap()
63
        );
64
    }
65
}
66