FromPreviousEnvironment::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
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