1 | <?php declare(strict_types = 1); |
||
7 | class RandomEnglishGenerator |
||
8 | { |
||
9 | |||
10 | private const POSSIBLE_WORD_TYPES = [ |
||
11 | 'noun', |
||
12 | 'countable_noun', |
||
13 | |||
14 | 'adjective', |
||
15 | 'preposition', |
||
16 | 'conjunction', |
||
17 | 'contraction', |
||
18 | 'control_verb', |
||
19 | |||
20 | 'sequence_adverb', |
||
21 | 'frequency_adverb', |
||
22 | |||
23 | // pluralize and ing these? |
||
24 | 'intransitive_verb', |
||
25 | 'irregular_verb', |
||
26 | 'transitive_verb', |
||
27 | 'verb', |
||
28 | 'adverb', |
||
29 | |||
30 | 'intransitive_verb_ing', |
||
31 | 'irregular_verb_ing', |
||
32 | 'transitive_verb_ing', |
||
33 | 'verb_ing', |
||
34 | |||
35 | |||
36 | // positions |
||
37 | 'locative', |
||
38 | |||
39 | 'plural_noun', |
||
40 | |||
41 | |||
42 | // names |
||
43 | 'mens_name', |
||
44 | 'womens_name', |
||
45 | ]; |
||
46 | |||
47 | /** @var string configuration file for sentences */ |
||
48 | private $config = ''; |
||
49 | |||
50 | public function __construct() |
||
55 | |||
56 | |||
57 | /** @param string $newConfig configuration file of how sentence structures */ |
||
58 | public function setConfig(string $newConfig): void |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Generate a random sentence |
||
66 | * |
||
67 | * @param bool $titleCase true to generate a title, false (default) to generate a sentence |
||
68 | * @return string a random sentence |
||
69 | */ |
||
70 | public function sentence(bool $titleCase = false): string |
||
143 | |||
144 | |||
145 | /** |
||
146 | * Generate a random title |
||
147 | * |
||
148 | * @return string a random sentence, all in caps, no trailing full stop |
||
149 | */ |
||
150 | public function title(): string |
||
154 | |||
155 | |||
156 | /** |
||
157 | * @param int $maxSentences The maximum number of sentences |
||
158 | * @return string a paragraph of random sentences |
||
159 | */ |
||
160 | public function paragraph(int $maxSentences = 10): string |
||
171 | |||
172 | |||
173 | /** @return string a plural noun */ |
||
174 | public function pluralNoun(): string |
||
180 | |||
181 | |||
182 | /** @return string a plural verb */ |
||
183 | public function pluralVerb(): string |
||
190 | |||
191 | |||
192 | /** @return string doing version of a verb */ |
||
193 | public function verbing(): string |
||
200 | |||
201 | |||
202 | /** |
||
203 | * @param string $wordType the type of word, e.g. noun, verb |
||
204 | * @return string a random word for the given word type |
||
205 | */ |
||
206 | private function getRandomWord(string $wordType): string |
||
214 | } |
||
215 |