Total Complexity | 10 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class SolutionGenerator |
||
14 | { |
||
15 | const NUMBER_OF_RANDOM_STARTERS = 11; |
||
16 | |||
17 | /** |
||
18 | * @var Grid |
||
19 | */ |
||
20 | private $grid; |
||
21 | |||
22 | /** |
||
23 | * @var BacktrackSolver |
||
24 | */ |
||
25 | private $solver; |
||
26 | |||
27 | public function __construct(BacktrackSolver $solver) |
||
28 | { |
||
29 | $this->solver = $solver; |
||
30 | } |
||
31 | |||
32 | public function generate(): Grid |
||
33 | { |
||
34 | do { |
||
35 | $this->grid = new Grid(); |
||
36 | $this->placeRandomStarters(); |
||
37 | } while (!$this->gridIsSolvable()); |
||
38 | |||
39 | return $this->grid; |
||
40 | } |
||
41 | |||
42 | private function placeRandomStarters(): void |
||
48 | } while (!GridValidator::gridIsValid($this->grid)); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | private function getRandomEmptyLocation(): Location |
||
59 | } |
||
60 | |||
61 | private function gridIsSolvable(): bool |
||
72 |
This check looks for private methods that have been defined, but are not used inside the class.