1 | <?php |
||
14 | class CommandExtractor |
||
15 | { |
||
16 | private $config; |
||
17 | private $error; |
||
18 | private $messageUtility; |
||
19 | private $dictionary; |
||
20 | private $commandContainer; |
||
21 | |||
22 | /** |
||
23 | * @param null $message |
||
24 | * |
||
25 | * @return Command|void |
||
26 | */ |
||
27 | 8 | public function getCommandByMessage($message) |
|
28 | { |
||
29 | 8 | if (empty($message)) { |
|
30 | 1 | $this->setError('Message is empty'); |
|
31 | |||
32 | 1 | return; |
|
33 | } |
||
34 | |||
35 | /* |
||
36 | * Process the message and find explicitly specified command |
||
37 | */ |
||
38 | 7 | return $this->getCommandObjectByMessage($message); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param $message |
||
43 | * |
||
44 | * @return array |
||
45 | */ |
||
46 | 4 | public function countKeywordOccurrence($message) |
|
68 | |||
69 | /** |
||
70 | * @param Command $command |
||
71 | * @param $message |
||
72 | * |
||
73 | * @return array|void |
||
74 | */ |
||
75 | 4 | private function commandKeywordOccurrence(Command $command, $message) |
|
88 | |||
89 | /** |
||
90 | * @param $message |
||
91 | * |
||
92 | * @return Command|void |
||
93 | */ |
||
94 | 7 | private function getCommandObjectByMessage($message) |
|
116 | |||
117 | /** |
||
118 | * @param $command |
||
119 | * |
||
120 | * @return Command|void |
||
121 | */ |
||
122 | 5 | private function getCommandObjectByCommand($command) |
|
132 | |||
133 | /** |
||
134 | * Validate the command object. |
||
135 | * |
||
136 | * @param Command|null $commandObject |
||
137 | * |
||
138 | * @return bool |
||
139 | */ |
||
140 | 5 | private function validateCommandObject($commandObject) |
|
153 | |||
154 | /** |
||
155 | * @return string |
||
156 | */ |
||
157 | 4 | public function getError() |
|
161 | |||
162 | /** |
||
163 | * @param string $error |
||
164 | */ |
||
165 | 5 | public function setError($error) |
|
169 | |||
170 | /** |
||
171 | * @return Config |
||
172 | */ |
||
173 | 4 | public function getConfig() |
|
181 | |||
182 | /** |
||
183 | * @param Config $config |
||
184 | */ |
||
185 | 1 | public function setConfig(Config $config) |
|
189 | |||
190 | /** |
||
191 | * @return MessageUtility |
||
192 | */ |
||
193 | 8 | public function getMessageUtility() |
|
201 | |||
202 | /** |
||
203 | * @param MessageUtility $messageUtility |
||
204 | */ |
||
205 | 8 | public function setMessageUtility(MessageUtility $messageUtility) |
|
209 | |||
210 | /** |
||
211 | * @return Dictionary |
||
212 | */ |
||
213 | 4 | public function getDictionary() |
|
221 | |||
222 | /** |
||
223 | * @param Dictionary $dictionary |
||
224 | */ |
||
225 | 4 | public function setDictionary(Dictionary $dictionary) |
|
229 | |||
230 | /** |
||
231 | * @return CommandContainer |
||
232 | */ |
||
233 | 8 | public function getCommandContainer() |
|
241 | |||
242 | /** |
||
243 | * @param CommandContainer $commandContainer |
||
244 | */ |
||
245 | 8 | public function setCommandContainer(CommandContainer $commandContainer) |
|
249 | } |
||
250 |