@@ -149,17 +149,17 @@ |
||
| 149 | 149 | */ |
| 150 | 150 | public function get_event($command) |
| 151 | 151 | { |
| 152 | - $events = $this->events; |
|
| 152 | + $events = $this->events; |
|
| 153 | 153 | |
| 154 | - foreach($events->events as $event) |
|
| 155 | - { |
|
| 156 | - $checker = $event->getChecker(); |
|
| 157 | - $closureReflection = new ReflectionFunction($checker); |
|
| 154 | + foreach($events->events as $event) |
|
| 155 | + { |
|
| 156 | + $checker = $event->getChecker(); |
|
| 157 | + $closureReflection = new ReflectionFunction($checker); |
|
| 158 | 158 | $variables = $closureReflection->getStaticVariables(); |
| 159 | 159 | |
| 160 | - if(preg_match('/'.$variables['name'].'/', $command)) |
|
| 161 | - return $event; |
|
| 162 | - } |
|
| 160 | + if(preg_match('/'.$variables['name'].'/', $command)) |
|
| 161 | + return $event; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | return false; |
| 165 | 165 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | public function run() |
| 140 | 140 | { |
| 141 | 141 | if ($data = BotApi::jsonValidate($this->getRawBody(), true)) { |
| 142 | - $this->handle([Update::fromResponse($data)]); |
|
| 142 | + $this->handle([ Update::fromResponse($data) ]); |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | /** |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | { |
| 152 | 152 | $events = $this->events; |
| 153 | 153 | |
| 154 | - foreach($events->events as $event) |
|
| 154 | + foreach ($events->events as $event) |
|
| 155 | 155 | { |
| 156 | 156 | $checker = $event->getChecker(); |
| 157 | 157 | $closureReflection = new ReflectionFunction($checker); |
| 158 | 158 | $variables = $closureReflection->getStaticVariables(); |
| 159 | 159 | |
| 160 | - if(preg_match('/'.$variables['name'].'/', $command)) |
|
| 160 | + if (preg_match('/' . $variables[ 'name' ] . '/', $command)) |
|
| 161 | 161 | return $event; |
| 162 | 162 | } |
| 163 | 163 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected static function getEvent(Closure $action) |
| 180 | 180 | { |
| 181 | - return function (Update $update) use ($action) { |
|
| 181 | + return function(Update $update) use ($action) { |
|
| 182 | 182 | $message = $update->getMessage(); |
| 183 | 183 | if (!$message) { |
| 184 | 184 | return true; |
@@ -186,10 +186,10 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | preg_match(self::REGEXP, $message->getText(), $matches); |
| 188 | 188 | |
| 189 | - if (isset($matches[3]) && !empty($matches[3])) { |
|
| 190 | - $parameters = str_getcsv($matches[3], chr(32)); |
|
| 189 | + if (isset($matches[ 3 ]) && !empty($matches[ 3 ])) { |
|
| 190 | + $parameters = str_getcsv($matches[ 3 ], chr(32)); |
|
| 191 | 191 | } else { |
| 192 | - $parameters = []; |
|
| 192 | + $parameters = [ ]; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | array_unshift($parameters, $message); |
@@ -206,104 +206,104 @@ discard block |
||
| 206 | 206 | |
| 207 | 207 | protected static function getEditedMessageEvent(Closure $action) |
| 208 | 208 | { |
| 209 | - return function (Update $update) use ($action) { |
|
| 209 | + return function(Update $update) use ($action) { |
|
| 210 | 210 | if (!$update->getEditedMessage()) { |
| 211 | 211 | return true; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | $reflectionAction = new ReflectionFunction($action); |
| 215 | - $reflectionAction->invokeArgs([$update->getEditedMessage()]); |
|
| 215 | + $reflectionAction->invokeArgs([ $update->getEditedMessage() ]); |
|
| 216 | 216 | return false; |
| 217 | 217 | }; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | protected static function getChannelPostEvent(Closure $action) |
| 221 | 221 | { |
| 222 | - return function (Update $update) use ($action) { |
|
| 222 | + return function(Update $update) use ($action) { |
|
| 223 | 223 | if (!$update->getChannelPost()) { |
| 224 | 224 | return true; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $reflectionAction = new ReflectionFunction($action); |
| 228 | - $reflectionAction->invokeArgs([$update->getChannelPost()]); |
|
| 228 | + $reflectionAction->invokeArgs([ $update->getChannelPost() ]); |
|
| 229 | 229 | return false; |
| 230 | 230 | }; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | protected static function getCallbackQueryEvent(Closure $action) |
| 234 | 234 | { |
| 235 | - return function (Update $update) use ($action) { |
|
| 235 | + return function(Update $update) use ($action) { |
|
| 236 | 236 | if (!$update->getCallbackQuery()) { |
| 237 | 237 | return true; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | $reflectionAction = new ReflectionFunction($action); |
| 241 | - $reflectionAction->invokeArgs([$update->getCallbackQuery()]); |
|
| 241 | + $reflectionAction->invokeArgs([ $update->getCallbackQuery() ]); |
|
| 242 | 242 | return false; |
| 243 | 243 | }; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | protected static function getEditedChannelPostEvent(Closure $action) |
| 247 | 247 | { |
| 248 | - return function (Update $update) use ($action) { |
|
| 248 | + return function(Update $update) use ($action) { |
|
| 249 | 249 | if (!$update->getEditedChannelPost()) { |
| 250 | 250 | return true; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | $reflectionAction = new ReflectionFunction($action); |
| 254 | - $reflectionAction->invokeArgs([$update->getEditedChannelPost()]); |
|
| 254 | + $reflectionAction->invokeArgs([ $update->getEditedChannelPost() ]); |
|
| 255 | 255 | return false; |
| 256 | 256 | }; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | protected static function getInlineQueryEvent(Closure $action) |
| 260 | 260 | { |
| 261 | - return function (Update $update) use ($action) { |
|
| 261 | + return function(Update $update) use ($action) { |
|
| 262 | 262 | if (!$update->getInlineQuery()) { |
| 263 | 263 | return true; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | $reflectionAction = new ReflectionFunction($action); |
| 267 | - $reflectionAction->invokeArgs([$update->getInlineQuery()]); |
|
| 267 | + $reflectionAction->invokeArgs([ $update->getInlineQuery() ]); |
|
| 268 | 268 | return false; |
| 269 | 269 | }; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | protected static function getChosenInlineResultEvent(Closure $action) |
| 273 | 273 | { |
| 274 | - return function (Update $update) use ($action) { |
|
| 274 | + return function(Update $update) use ($action) { |
|
| 275 | 275 | if (!$update->getChosenInlineResult()) { |
| 276 | 276 | return true; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $reflectionAction = new ReflectionFunction($action); |
| 280 | - $reflectionAction->invokeArgs([$update->getChosenInlineResult()]); |
|
| 280 | + $reflectionAction->invokeArgs([ $update->getChosenInlineResult() ]); |
|
| 281 | 281 | return false; |
| 282 | 282 | }; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | protected static function getShippingQueryEvent(Closure $action) |
| 286 | 286 | { |
| 287 | - return function (Update $update) use ($action) { |
|
| 287 | + return function(Update $update) use ($action) { |
|
| 288 | 288 | if (!$update->getShippingQuery()) { |
| 289 | 289 | return true; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $reflectionAction = new ReflectionFunction($action); |
| 293 | - $reflectionAction->invokeArgs([$update->getShippingQuery()]); |
|
| 293 | + $reflectionAction->invokeArgs([ $update->getShippingQuery() ]); |
|
| 294 | 294 | return false; |
| 295 | 295 | }; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | protected static function getPreCheckoutQueryEvent(Closure $action) |
| 299 | 299 | { |
| 300 | - return function (Update $update) use ($action) { |
|
| 300 | + return function(Update $update) use ($action) { |
|
| 301 | 301 | if (!$update->getPreCheckoutQuery()) { |
| 302 | 302 | return true; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $reflectionAction = new ReflectionFunction($action); |
| 306 | - $reflectionAction->invokeArgs([$update->getPreCheckoutQuery()]); |
|
| 306 | + $reflectionAction->invokeArgs([ $update->getPreCheckoutQuery() ]); |
|
| 307 | 307 | return false; |
| 308 | 308 | }; |
| 309 | 309 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | protected static function getChecker($name) |
| 319 | 319 | { |
| 320 | - return function (Update $update) use ($name) { |
|
| 320 | + return function(Update $update) use ($name) { |
|
| 321 | 321 | $message = $update->getMessage(); |
| 322 | 322 | if (is_null($message) || !strlen($message->getText())) { |
| 323 | 323 | return false; |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | preg_match(self::REGEXP, $message->getText(), $matches); |
| 327 | 327 | |
| 328 | - return !empty($matches) && $matches[1] == $name; |
|
| 328 | + return !empty($matches) && $matches[ 1 ] == $name; |
|
| 329 | 329 | }; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | */ |
| 337 | 337 | protected static function getEditedMessageChecker() |
| 338 | 338 | { |
| 339 | - return function (Update $update) { |
|
| 339 | + return function(Update $update) { |
|
| 340 | 340 | return !is_null($update->getEditedMessage()); |
| 341 | 341 | }; |
| 342 | 342 | } |
@@ -348,7 +348,7 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | protected static function getChannelPostChecker() |
| 350 | 350 | { |
| 351 | - return function (Update $update) { |
|
| 351 | + return function(Update $update) { |
|
| 352 | 352 | return !is_null($update->getChannelPost()); |
| 353 | 353 | }; |
| 354 | 354 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | protected static function getCallbackQueryChecker() |
| 362 | 362 | { |
| 363 | - return function (Update $update) { |
|
| 363 | + return function(Update $update) { |
|
| 364 | 364 | return !is_null($update->getCallbackQuery()); |
| 365 | 365 | }; |
| 366 | 366 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | protected static function getEditedChannelPostChecker() |
| 374 | 374 | { |
| 375 | - return function (Update $update) { |
|
| 375 | + return function(Update $update) { |
|
| 376 | 376 | return !is_null($update->getEditedChannelPost()); |
| 377 | 377 | }; |
| 378 | 378 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | protected static function getChosenInlineResultChecker() |
| 386 | 386 | { |
| 387 | - return function (Update $update) { |
|
| 387 | + return function(Update $update) { |
|
| 388 | 388 | return !is_null($update->getChosenInlineResult()); |
| 389 | 389 | }; |
| 390 | 390 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | protected static function getInlineQueryChecker() |
| 398 | 398 | { |
| 399 | - return function (Update $update) { |
|
| 399 | + return function(Update $update) { |
|
| 400 | 400 | return !is_null($update->getInlineQuery()); |
| 401 | 401 | }; |
| 402 | 402 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | */ |
| 409 | 409 | protected static function getShippingQueryChecker() |
| 410 | 410 | { |
| 411 | - return function (Update $update) { |
|
| 411 | + return function(Update $update) { |
|
| 412 | 412 | return !is_null($update->getShippingQuery()); |
| 413 | 413 | }; |
| 414 | 414 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | protected static function getPreCheckoutQueryChecker() |
| 422 | 422 | { |
| 423 | - return function (Update $update) { |
|
| 423 | + return function(Update $update) { |
|
| 424 | 424 | return !is_null($update->getPreCheckoutQuery()); |
| 425 | 425 | }; |
| 426 | 426 | } |
@@ -428,9 +428,9 @@ discard block |
||
| 428 | 428 | public function __call($name, array $arguments) |
| 429 | 429 | { |
| 430 | 430 | if (method_exists($this, $name)) { |
| 431 | - return call_user_func_array([$this, $name], $arguments); |
|
| 431 | + return call_user_func_array([ $this, $name ], $arguments); |
|
| 432 | 432 | } elseif (method_exists($this->api, $name)) { |
| 433 | - return call_user_func_array([$this->api, $name], $arguments); |
|
| 433 | + return call_user_func_array([ $this->api, $name ], $arguments); |
|
| 434 | 434 | } |
| 435 | 435 | throw new BadMethodCallException("Method {$name} not exists"); |
| 436 | 436 | } |
@@ -157,8 +157,9 @@ |
||
| 157 | 157 | $closureReflection = new ReflectionFunction($checker); |
| 158 | 158 | $variables = $closureReflection->getStaticVariables(); |
| 159 | 159 | |
| 160 | - if(preg_match('/'.$variables['name'].'/', $command)) |
|
| 161 | - return $event; |
|
| 160 | + if(preg_match('/'.$variables['name'].'/', $command)) { |
|
| 161 | + return $event; |
|
| 162 | + } |
|
| 162 | 163 | } |
| 163 | 164 | |
| 164 | 165 | return false; |