public function move(Move $new) { foreach ($this->moves as $move) { for ($row = 0; $row <= 2; $row++) { for ($col = 0; $col <= 2; $col++) { if ($move == $new) { throw new \RuntimeException('Already moved here'); } } } } $this->moves[] = $new; $currentName = $this->currentPlayer()->get('name'); $this->movesPerPlayer[$currentName][$new->get('row')][$new->get('col')] = true; return end($this->moves); }