FromPreviousEnvironment   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A environment() 0 3 1
A estimate() 0 3 1
A state() 0 5 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Pathfinder\Estimate;
4
5
use Stratadox\Pathfinder\Environment;
6
use Stratadox\Pathfinder\Heuristic;
7
8
final class FromPreviousEnvironment implements Heuristic
9
{
10
    private $heuristic;
11
    private $environment;
12
13
    private function __construct(Heuristic $heuristic, Environment $environment)
14
    {
15
        $this->heuristic = $heuristic;
16
        $this->environment = $environment;
17
    }
18
19
    public static function state(
20
        Heuristic $heuristic,
21
        Environment $environment
22
    ): Heuristic {
23
        return new self($heuristic, $environment);
24
    }
25
26
    public function estimate(string $start, string $goal): float
27
    {
28
        return $this->heuristic->estimate($start, $goal);
29
    }
30
31
    public function environment(): Environment
32
    {
33
        return $this->environment;
34
    }
35
}
36