| 1 | <?php |
||
| 5 | class Word |
||
| 6 | { |
||
| 7 | private $word; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Word constructor. |
||
| 11 | * |
||
| 12 | * @param $word |
||
| 13 | */ |
||
| 14 | 111 | public function __construct($word) |
|
| 18 | |||
| 19 | /** |
||
| 20 | * Get the letters of the word |
||
| 21 | * |
||
| 22 | * @return string[] |
||
| 23 | */ |
||
| 24 | 42 | public function getLetters() |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Build the word from played letters |
||
| 31 | * |
||
| 32 | * @param string[] $playedLetters |
||
| 33 | * |
||
| 34 | * @return string |
||
| 35 | */ |
||
| 36 | 42 | public function buildWord($playedLetters) |
|
| 49 | |||
| 50 | /** |
||
| 51 | * Checks if the answer is valid |
||
| 52 | * |
||
| 53 | * @param string $answer |
||
| 54 | * |
||
| 55 | * @return bool |
||
| 56 | */ |
||
| 57 | 12 | public function isValid($answer) |
|
| 61 | |||
| 62 | /** |
||
| 63 | * Returns if the letter is contained in the word |
||
| 64 | * |
||
| 65 | * @param string $letter |
||
| 66 | * |
||
| 67 | * @return boolean |
||
| 68 | */ |
||
| 69 | 15 | public function contains($letter) |
|
| 73 | |||
| 74 | /** |
||
| 75 | * @param string $word |
||
| 76 | * |
||
| 77 | * @return bool |
||
| 78 | */ |
||
| 79 | 9 | public function equals($word) |
|
| 83 | |||
| 84 | /** |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | 27 | public function __toString() |
|
| 91 | } |
||
| 92 |