| Total Complexity | 7 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 18 | final class PuzzleSolution implements Solution |
||
| 19 | { |
||
| 20 | /** @var Moves */ |
||
| 21 | private $moves; |
||
| 22 | /** @var Puzzle */ |
||
| 23 | private $state; |
||
| 24 | /** @var Puzzle */ |
||
| 25 | private $original; |
||
| 26 | |||
| 27 | public function __construct(Moves $moves, Puzzle $state, Puzzle $original) |
||
| 28 | { |
||
| 29 | $this->moves = $moves; |
||
| 30 | $this->state = $state; |
||
| 31 | $this->original = $original; |
||
| 32 | } |
||
| 33 | |||
| 34 | public static function fromSolved(Puzzle $puzzle, Puzzle $original): self |
||
| 35 | { |
||
| 36 | assert($puzzle->isSolved()); |
||
| 37 | return new self($puzzle->movesSoFar(), $puzzle, $original); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function moves(): Moves |
||
| 41 | { |
||
| 42 | return $this->moves; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function state(): Puzzle |
||
| 46 | { |
||
| 47 | return $this->state; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function cost(): float |
||
| 51 | { |
||
| 52 | return $this->moves->cost(); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function original(): Puzzle |
||
| 58 | } |
||
| 59 | |||
| 60 | public function __toString(): string |
||
| 63 | } |
||
| 64 | } |
||
| 65 |