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 string |
||
|
|||
93 | */ |
||
94 | 7 | private function getCommandObjectByMessage($message) |
|
109 | |||
110 | /** |
||
111 | * @return mixed|void |
||
112 | */ |
||
113 | 3 | private function checkDefaultCommand() |
|
124 | |||
125 | /** |
||
126 | * @param $command |
||
127 | * |
||
128 | * @return Command|void |
||
129 | */ |
||
130 | 7 | private function getCommandObjectByCommand($command) |
|
144 | |||
145 | /** |
||
146 | * Validate the command object. |
||
147 | * |
||
148 | * @param Command|null $commandObject |
||
149 | * |
||
150 | * @return bool |
||
151 | */ |
||
152 | 5 | private function validateCommandObject($commandObject) |
|
165 | |||
166 | /** |
||
167 | * @return string |
||
168 | */ |
||
169 | 4 | public function getError() |
|
173 | |||
174 | /** |
||
175 | * @param string $error |
||
176 | */ |
||
177 | 5 | public function setError($error) |
|
181 | |||
182 | /** |
||
183 | * @return Config |
||
184 | */ |
||
185 | 4 | public function getConfig() |
|
193 | |||
194 | /** |
||
195 | * @param Config $config |
||
196 | */ |
||
197 | 1 | public function setConfig(Config $config) |
|
201 | |||
202 | /** |
||
203 | * @return MessageUtility |
||
204 | */ |
||
205 | 8 | public function getMessageUtility() |
|
213 | |||
214 | /** |
||
215 | * @param MessageUtility $messageUtility |
||
216 | */ |
||
217 | 8 | public function setMessageUtility(MessageUtility $messageUtility) |
|
221 | |||
222 | /** |
||
223 | * @return Dictionary |
||
224 | */ |
||
225 | 4 | public function getDictionary() |
|
233 | |||
234 | /** |
||
235 | * @param Dictionary $dictionary |
||
236 | */ |
||
237 | 4 | public function setDictionary(Dictionary $dictionary) |
|
241 | |||
242 | /** |
||
243 | * @return CommandContainer |
||
244 | */ |
||
245 | 8 | public function getCommandContainer() |
|
253 | |||
254 | /** |
||
255 | * @param CommandContainer $commandContainer |
||
256 | */ |
||
257 | 8 | public function setCommandContainer(CommandContainer $commandContainer) |
|
261 | } |
||
262 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.