1 | <?php declare(strict_types = 1); |
||
5 | class RandomEnglishGenerator |
||
6 | { |
||
7 | |||
8 | private const POSSIBLE_WORD_TYPES = [ |
||
9 | 'noun', |
||
10 | 'countable_noun', |
||
11 | |||
12 | 'adjective', |
||
13 | 'preposition', |
||
14 | 'conjunction', |
||
15 | 'contraction', |
||
16 | 'control_verb', |
||
17 | |||
18 | 'sequence_adverb', |
||
19 | 'frequency_adverb', |
||
20 | |||
21 | // pluralize and ing these? |
||
22 | 'intransitive_verb', |
||
23 | 'irregular_verb', |
||
24 | 'transitive_verb', |
||
25 | 'verb', |
||
26 | |||
27 | |||
28 | // positions |
||
29 | 'locative', |
||
30 | |||
31 | |||
32 | ]; |
||
33 | |||
34 | /** @var string configuration file for sentences */ |
||
35 | private $config = ''; |
||
36 | |||
37 | public function __construct() |
||
42 | |||
43 | /** @param string $newConfig configuration file of how sentence structures */ |
||
44 | public function setConfig(string $newConfig): void |
||
48 | |||
49 | /** |
||
50 | * Generate a random sentence |
||
51 | * |
||
52 | * @param bool $titleCase true to generate a title, false (default) to generate a sentence |
||
53 | * @return string a random sentence |
||
54 | */ |
||
55 | public function sentence(bool $titleCase = false): string |
||
100 | |||
101 | /** |
||
102 | * Generate a random title |
||
103 | * |
||
104 | * @return string a random sentence, all in caps, no trailing full stop |
||
105 | */ |
||
106 | public function title(): string |
||
110 | |||
111 | /** |
||
112 | * @param int $maxSentences The maximum number of sentences |
||
113 | * @return string a paragraph of random sentences |
||
114 | */ |
||
115 | public function paragraph(int $maxSentences = 10): string |
||
126 | |||
127 | /** @return string a plural noun */ |
||
128 | public function pluralNoun(): string |
||
134 | |||
135 | /** @return string a plural verb */ |
||
136 | public function pluralVerb(): string |
||
143 | |||
144 | /** @return string doing version of a verb */ |
||
145 | public function verbing(): string |
||
152 | |||
153 | /** |
||
154 | * @param string $wordType the type of word, e.g. noun, verb |
||
155 | * @return string a random word for the given word type |
||
156 | */ |
||
157 | private function getRandomWord(string $wordType): string |
||
165 | |||
166 | } |
||
167 |