@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function driver($driver) |
77 | 77 | { |
78 | - $this->driver = Collection::make($driver)->transform(function ($driver) { |
|
78 | + $this->driver = Collection::make($driver)->transform(function($driver) { |
|
79 | 79 | if (class_exists($driver) && is_subclass_of($driver, DriverInterface::class)) { |
80 | 80 | $driver = basename(str_replace('\\', '/', $driver)); |
81 | 81 | $driver = preg_replace('/(.*)(Driver)$/', '$1', $driver); |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function middleware($middleware) |
142 | 142 | { |
143 | - if (! is_array($middleware)) { |
|
143 | + if ( ! is_array($middleware)) { |
|
144 | 144 | $middleware = [$middleware]; |
145 | 145 | } |
146 | 146 | |
147 | - $this->middleware = Collection::make($middleware)->filter(function ($item) { |
|
147 | + $this->middleware = Collection::make($middleware)->filter(function($item) { |
|
148 | 148 | return $item instanceof MiddlewareInterface; |
149 | 149 | })->merge($this->middleware)->toArray(); |
150 | 150 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | * |
39 | 39 | * @param string $pattern |
40 | 40 | * @param Closure|string $callback |
41 | - * @param array|null $recipients |
|
41 | + * @param string|null $recipients |
|
42 | 42 | * @param string|null $driver |
43 | 43 | */ |
44 | 44 | public function __construct($pattern, $callback, $recipients = null, $driver = null) |
@@ -102,8 +102,8 @@ |
||
102 | 102 | $botman = new BotMan($cache, DriverManager::loadFromName('Null', $config), $config, $storageDriver); |
103 | 103 | $botman->runsOnSocket(true); |
104 | 104 | |
105 | - $socket->on('connection', function ($conn) use ($botman, $driverManager) { |
|
106 | - $conn->on('data', function ($data) use ($botman, $driverManager) { |
|
105 | + $socket->on('connection', function($conn) use ($botman, $driverManager) { |
|
106 | + $conn->on('data', function($data) use ($botman, $driverManager) { |
|
107 | 107 | $requestData = json_decode($data, true); |
108 | 108 | $request = new Request($requestData['query'], $requestData['request'], $requestData['attributes'], [], [], [], $requestData['content']); |
109 | 109 | $driver = $driverManager->getMatchingDriver($request); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function register() |
17 | 17 | { |
18 | - $this->app->singleton('botman', function ($app) { |
|
18 | + $this->app->singleton('botman', function($app) { |
|
19 | 19 | $storage = new FileStorage(storage_path('botman')); |
20 | 20 | |
21 | 21 | return BotManFactory::create(config('botman', []), new LaravelCache(), $app->make('request'), |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | */ |
185 | 185 | public function getBotMessages() |
186 | 186 | { |
187 | - return Collection::make($this->getDriver()->getMessages())->filter(function (IncomingMessage $message) { |
|
187 | + return Collection::make($this->getDriver()->getMessages())->filter(function(IncomingMessage $message) { |
|
188 | 188 | return $message->isFromBot(); |
189 | 189 | })->toArray(); |
190 | 190 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | { |
235 | 235 | preg_match_all(Matcher::PARAM_NAME_REGEX, $value, $matches); |
236 | 236 | |
237 | - return array_map(function ($m) { |
|
237 | + return array_map(function($m) { |
|
238 | 238 | return trim($m, '?'); |
239 | 239 | }, $matches[1]); |
240 | 240 | } |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | if ($driverEvent instanceof DriverEventInterface) { |
346 | 346 | $this->firedDriverEvents = true; |
347 | 347 | |
348 | - Collection::make($this->events)->filter(function ($event) use ($driverEvent) { |
|
348 | + Collection::make($this->events)->filter(function($event) use ($driverEvent) { |
|
349 | 349 | return $driverEvent->getName() === $event['name']; |
350 | - })->each(function ($event) use ($driverEvent) { |
|
350 | + })->each(function($event) use ($driverEvent) { |
|
351 | 351 | /** |
352 | 352 | * Load the message, so driver events can reply. |
353 | 353 | */ |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | */ |
510 | 510 | public function ask($question, $next, $additionalParameters = [], $recipient = null, $driver = null) |
511 | 511 | { |
512 | - if (! is_null($recipient) && ! is_null($driver)) { |
|
512 | + if ( ! is_null($recipient) && ! is_null($driver)) { |
|
513 | 513 | if (is_string($driver)) { |
514 | 514 | $driver = DriverManager::loadFromName($driver, $this->config); |
515 | 515 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | */ |
582 | 582 | public function sendPayload($payload) |
583 | 583 | { |
584 | - return $this->middleware->applyMiddleware('sending', $payload, [], function ($payload) { |
|
584 | + return $this->middleware->applyMiddleware('sending', $payload, [], function($payload) { |
|
585 | 585 | $this->outgoingMessage = null; |
586 | 586 | |
587 | 587 | return $this->getDriver()->sendPayload($payload); |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | */ |
608 | 608 | protected function makeInvokableAction($action) |
609 | 609 | { |
610 | - if (! method_exists($action, '__invoke')) { |
|
610 | + if ( ! method_exists($action, '__invoke')) { |
|
611 | 611 | throw new UnexpectedValueException(sprintf( |
612 | 612 | 'Invalid hears action: [%s]', $action |
613 | 613 | )); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * Retrieve the chat message. |
172 | 172 | * |
173 | - * @return array |
|
173 | + * @return IncomingMessage[] |
|
174 | 174 | */ |
175 | 175 | public function getMessages() |
176 | 176 | { |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
584 | - * @param $payload |
|
584 | + * @param DriverInterface $payload |
|
585 | 585 | * @return mixed |
586 | 586 | */ |
587 | 587 | public function sendPayload($payload) |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | /** |
625 | 625 | * @param $callback |
626 | - * @return array|string|Closure |
|
626 | + * @return callable |
|
627 | 627 | * @throws UnexpectedValueException |
628 | 628 | */ |
629 | 629 | protected function getCallable($callback) |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
700 | - * @return array |
|
700 | + * @return string[] |
|
701 | 701 | */ |
702 | 702 | public function __sleep() |
703 | 703 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | // Try middleware first |
60 | 60 | if (count($middleware)) { |
61 | - return Collection::make($middleware)->reject(function (Matching $middleware) use ( |
|
61 | + return Collection::make($middleware)->reject(function(Matching $middleware) use ( |
|
62 | 62 | $message, |
63 | 63 | $pattern, |
64 | 64 | $regexMatched |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | */ |
78 | 78 | protected function isDriverValid($driverName, $allowedDrivers) |
79 | 79 | { |
80 | - if (! is_null($allowedDrivers)) { |
|
80 | + if ( ! is_null($allowedDrivers)) { |
|
81 | 81 | return Collection::make($allowedDrivers)->contains($driverName); |
82 | 82 | } |
83 | 83 |