| Total Complexity | 5 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class CCA |
||
| 8 | { |
||
| 9 | /** @var Config */ |
||
| 10 | protected $config; |
||
| 11 | |||
| 12 | /** @var Grid */ |
||
| 13 | protected $grid; |
||
| 14 | |||
| 15 | /** @var int */ |
||
| 16 | protected $generation = 0; |
||
| 17 | |||
| 18 | 6 | public function __construct(Config $config, Grid $grid) |
|
| 19 | { |
||
| 20 | 6 | $this->config = $config; |
|
| 21 | |||
| 22 | 6 | $this->grid = $grid; |
|
| 23 | 6 | } |
|
| 24 | |||
| 25 | 9 | public function cycle(int $cycles = 1): int |
|
| 26 | { |
||
| 27 | 9 | while ($cycles > 0) { |
|
| 28 | 6 | $this->grid->computeNextState(); |
|
| 29 | |||
| 30 | 6 | $this->grid->setNextState(); |
|
| 31 | |||
| 32 | 6 | $this->generation++; |
|
| 33 | |||
| 34 | 6 | $cycles--; |
|
| 35 | } |
||
| 36 | |||
| 37 | 9 | return $this->generation; |
|
| 38 | } |
||
| 39 | |||
| 40 | 3 | public function getState(): State |
|
| 43 | } |
||
| 44 | |||
| 45 | 3 | public function printCells() |
|
| 52 |