| Total Complexity | 4 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 9 | final class Estimate implements Heuristic |
||
| 10 | { |
||
| 11 | private $environment; |
||
| 12 | private $metric; |
||
| 13 | |||
| 14 | private function __construct( |
||
| 15 | Metric $metric, |
||
| 16 | Environment $environment |
||
| 17 | ) { |
||
| 18 | $this->metric = $metric; |
||
| 19 | $this->environment = $environment; |
||
| 20 | } |
||
| 21 | |||
| 22 | public static function costAs( |
||
| 23 | Metric $metric, |
||
| 24 | Environment $environment |
||
| 25 | ): Heuristic { |
||
| 26 | return new static($metric, $environment); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function estimate(string $start, string $goal): float |
||
| 30 | { |
||
| 31 | return $this->metric->distanceBetween( |
||
| 32 | $this->environment->positionOf($start), |
||
| 33 | $this->environment->positionOf($goal) |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | |||
| 37 | public function environment(): Environment |
||
| 40 | } |
||
| 41 | } |
||
| 42 |