@@ -13,7 +13,6 @@ |
||
| 13 | 13 | |
| 14 | 14 | use Domains\Room\RoomInterface; |
| 15 | 15 | use Illuminate\Support\Collection; |
| 16 | -use Interfaces\Gitter\StandartGitterRoom; |
|
| 17 | 16 | |
| 18 | 17 | /** |
| 19 | 18 | * Class RoomManager |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param Message $message |
| 39 | - * @return Status[]|Collection |
|
| 39 | + * @return Collection |
|
| 40 | 40 | */ |
| 41 | 41 | public function validate(Message $message) |
| 42 | 42 | { |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @param $value |
|
| 34 | + * @param \Domains\Middleware\MiddlewareInterface $value |
|
| 35 | 35 | * @param int $priority |
| 36 | 36 | * @return $this |
| 37 | 37 | */ |
@@ -20,7 +20,6 @@ |
||
| 20 | 20 | class UserMapper |
| 21 | 21 | { |
| 22 | 22 | /** |
| 23 | - * @param array|\StdClass $attributes |
|
| 24 | 23 | * @return User |
| 25 | 24 | * @throws InvalidArgumentException |
| 26 | 25 | */ |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public static function fromSlackObject(\Slack\User $user) |
| 28 | 28 | { |
| 29 | - $values = (new AttributeMapper((array) $user->data)) |
|
| 29 | + $values = (new AttributeMapper((array)$user->data)) |
|
| 30 | 30 | ->rename('id', 'gitter_id') |
| 31 | 31 | ->rename('name', 'login') |
| 32 | 32 | ->rename('real_name', 'name') |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $user = User::where('gitter_id', $values['gitter_id'])->first(); |
| 40 | 40 | if (!$user) { |
| 41 | - $user = User::unguarded(function () use ($values) { |
|
| 41 | + $user = User::unguarded(function() use ($values) { |
|
| 42 | 42 | return User::create($values); |
| 43 | 43 | }); |
| 44 | 44 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', |
| 23 | 23 | |
| 24 | - function ($matches) { |
|
| 24 | + function($matches) { |
|
| 25 | 25 | if (isset($matches[1]) && isset($matches[2])) |
| 26 | 26 | return "<".$matches[1]."|".$matches[2].">"; |
| 27 | 27 | else |
@@ -22,10 +22,11 @@ |
||
| 22 | 22 | $this->text = preg_replace_callback('%\[url\s*=\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu', |
| 23 | 23 | |
| 24 | 24 | function ($matches) { |
| 25 | - if (isset($matches[1]) && isset($matches[2])) |
|
| 26 | - return "<".$matches[1]."|".$matches[2].">"; |
|
| 27 | - else |
|
| 28 | - throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
| 25 | + if (isset($matches[1]) && isset($matches[2])) { |
|
| 26 | + return "<".$matches[1]."|".$matches[2].">"; |
|
| 27 | + } else { |
|
| 28 | + throw new \RuntimeException(sprintf("Text identified by '%d' has malformed BBCode urls", $this->id)); |
|
| 29 | + } |
|
| 29 | 30 | }, |
| 30 | 31 | |
| 31 | 32 | $this->text |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function sendMessage(RoomInterface $room, $message) |
| 69 | 69 | { |
| 70 | - $this->client->getChannelById($room->id())->then(function (\Slack\Channel $channel) use($message) { |
|
| 70 | + $this->client->getChannelById($room->id())->then(function(\Slack\Channel $channel) use($message) { |
|
| 71 | 71 | $this->client->apiCall('chat.postMessage', [ |
| 72 | - 'text' => (string) $this->parser->parse($message), |
|
| 72 | + 'text' => (string)$this->parser->parse($message), |
|
| 73 | 73 | 'channel' => $channel->getId(), |
| 74 | 74 | 'as_user' => true, |
| 75 | 75 | ]); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function listen(RoomInterface $room) |
| 85 | 85 | { |
| 86 | - $this->client->on('message', function (\Slack\Payload $msg) use($room) { |
|
| 86 | + $this->client->on('message', function(\Slack\Payload $msg) use($room) { |
|
| 87 | 87 | if ($msg->getData()['channel'] != $room->id()) { |
| 88 | 88 | return; |
| 89 | 89 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | ); |
| 100 | 100 | }); |
| 101 | 101 | |
| 102 | - $this->client->on('reaction_added', function (\Slack\Payload $payload) use($room) { |
|
| 102 | + $this->client->on('reaction_added', function(\Slack\Payload $payload) use($room) { |
|
| 103 | 103 | if ($payload->getData()['item']['type'] != 'message' and $payload->getData()['item']['channel'] != $room->id()) { |
| 104 | 104 | return; |
| 105 | 105 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | protected function logException(\Exception $e) |
| 173 | 173 | { |
| 174 | 174 | \Log::error( |
| 175 | - $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine() . "\n" . |
|
| 176 | - $e->getTraceAsString() . "\n" . |
|
| 177 | - str_repeat('=', 80) . "\n" |
|
| 175 | + $e->getMessage().' in '.$e->getFile().':'.$e->getLine()."\n". |
|
| 176 | + $e->getTraceAsString()."\n". |
|
| 177 | + str_repeat('=', 80)."\n" |
|
| 178 | 178 | ); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -35,13 +35,13 @@ |
||
| 35 | 35 | |
| 36 | 36 | $this->attributes = (new AttributeMapper($attributes)) |
| 37 | 37 | ->rename('channel', 'room_id') |
| 38 | - ->value('user', function ($user) use($room) { |
|
| 38 | + ->value('user', function($user) use($room) { |
|
| 39 | 39 | return $room->client()->getUserById($user); |
| 40 | 40 | }) |
| 41 | - ->value('ts', function ($date) { |
|
| 41 | + ->value('ts', function($date) { |
|
| 42 | 42 | return Carbon::createFromTimestamp($date)->setTimezone('Europe/Moscow'); |
| 43 | 43 | }, 'created_at') |
| 44 | - ->value('mentions', function ($ids) use($room) { |
|
| 44 | + ->value('mentions', function($ids) use($room) { |
|
| 45 | 45 | $users = []; |
| 46 | 46 | if (is_array($ids)) { |
| 47 | 47 | foreach ($ids as $userId) { |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | $result[] = sprintf('[*] [url=%s]%s[/url]', $link->link, $link->title); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if (! empty($result)) { |
|
| 97 | + if (!empty($result)) { |
|
| 98 | 98 | $result = '[list]'.implode(PHP_EOL, $result).'[/list]'; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | $this->text = preg_replace_callback('%\[i\]([\W\D\w\s]*?)\[/i\]%iu', |
| 28 | 28 | |
| 29 | - function ($matches) { |
|
| 29 | + function($matches) { |
|
| 30 | 30 | return "_".trim($matches[1], " ")."_"; |
| 31 | 31 | }, |
| 32 | 32 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $this->text = preg_replace_callback('%\[user\]([\W\D\w\s]*?)\[/user\]%iu', |
| 44 | 44 | |
| 45 | - function ($matches) { |
|
| 45 | + function($matches) { |
|
| 46 | 46 | $username = trim($matches[1]); |
| 47 | 47 | |
| 48 | 48 | return empty($username) ? "" : "@{$username}"; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->text = preg_replace_callback('%\[pre\]([\W\D\w\s]*?)\[/pre\]%iu', |
| 61 | 61 | |
| 62 | - function ($matches) { |
|
| 62 | + function($matches) { |
|
| 63 | 63 | return "`{$matches[1]}``"; |
| 64 | 64 | }, |
| 65 | 65 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $this->text = preg_replace_callback('%\[h([0-6]{1})\]([\W\D\w\s]*?)\[/h[0-6]?\]%iu', |
| 76 | 76 | |
| 77 | - function ($matches) { |
|
| 77 | + function($matches) { |
|
| 78 | 78 | $size = $matches[1]; |
| 79 | 79 | |
| 80 | 80 | return str_repeat('#', $size).' '.$matches[2].PHP_EOL; |