| 1 | <?php |
||
| 5 | class Word |
||
| 6 | { |
||
| 7 | private $word; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Word constructor. |
||
| 11 | * |
||
| 12 | * @param $word |
||
| 13 | */ |
||
| 14 | 132 | public function __construct($word) |
|
| 18 | |||
| 19 | /** |
||
| 20 | * Get the letters of the word |
||
| 21 | * |
||
| 22 | * @return string[] |
||
| 23 | */ |
||
| 24 | 48 | public function getLetters() |
|
| 30 | |||
| 31 | /** |
||
| 32 | * Build the word from played letters |
||
| 33 | * |
||
| 34 | * @param string[] $playedLetters |
||
| 35 | * |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | 45 | public function buildWord($playedLetters) |
|
| 54 | |||
| 55 | /** |
||
| 56 | * Checks if the answer is valid |
||
| 57 | * |
||
| 58 | * @param string $answer |
||
| 59 | * |
||
| 60 | * @return bool |
||
| 61 | */ |
||
| 62 | 15 | public function isValid($answer) |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Returns if the letter is contained in the word |
||
| 69 | * |
||
| 70 | * @param string $letter |
||
| 71 | * |
||
| 72 | * @return boolean |
||
| 73 | */ |
||
| 74 | 18 | public function contains($letter) |
|
| 78 | |||
| 79 | /** |
||
| 80 | * @param string $word |
||
| 81 | * |
||
| 82 | * @return bool |
||
| 83 | */ |
||
| 84 | 12 | public function equals($word) |
|
| 88 | |||
| 89 | /** |
||
| 90 | * @return string |
||
| 91 | */ |
||
| 92 | 30 | public function __toString() |
|
| 96 | } |
||
| 97 |