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   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 24
dl 0
loc 56
c 0
b 0
f 0
ccs 23
cts 23
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 4 1
A buildPathBetween() 0 18 3
A __construct() 0 8 1
A getPath() 0 9 2
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