Passed
Push — master ( 979da0...21dcf7 )
by Jesse
01:38
created

PathRetracer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A retrace() 0 13 2
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Pathfinder\Reconstruction;
4
5
final class PathRetracer
6
{
7
    public function retrace(
8
        string $start,
9
        string $goal,
10
        array $breadcrumbs
11
    ): array {
12
        $node = $goal;
13
        $path = [];
14
        while (isset($breadcrumbs[$node])) {
15
            $path[] = $node;
16
            $node = $breadcrumbs[$node];
17
        }
18
        $path[] = $start;
19
        return array_reverse($path);
20
    }
21
}
22