/** * @param string $gameId * @param string $letter */ private function correctlyGuessedLetters($gameId, $outputLetters) { // Throw the event $this->apply(new LetterGuessedCorrectly($gameId, $outputLetters)); $all_found = false; // check if the array has the same size if ($this->lettersCorrectlyGuessed->lengthOfContainer() == $this->word->getLenghtOfWord()) { // convert string to array $arrLetters = $this->word->getLocationsAndLettersOfContainer($outputLetters); foreach ($arrLetters as $l) { if ($this->word->wordContainsLetter($l) === false) { $all_found = false; break; } $all_found = true; } } if ($all_found) { $this->apply(new GameWon($this->gameId, new \DateTime("now"))); } }