private function validate(BoggleWord $word) { if ($word->getLength() < 3) { throw new IllegalWordLengthException("Word should at least have 2 characters"); } if ($this->words->contains($word)) { throw new WordAlreadyEnteredException("Word was already entered before"); } if (!$word->isPossibleInLayout($this->grid)) { throw new WordNotPossibleException("Word is impossible to make"); } if (!$this->dictionary->contains($word)) { throw new WordNotInDictionaryException("Word doesn't exist in dictionary"); } }