Completed
Push — master ( fae82d...75d992 )
by Armando
05:54 queued 03:56
created
src/ConversationDB.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
         }
85 85
 
86 86
         try {
87
-            $sth    = self::$pdo->prepare('INSERT INTO `' . TB_CONVERSATION . '`
87
+            $sth = self::$pdo->prepare('INSERT INTO `' . TB_CONVERSATION . '`
88 88
                 (
89 89
                 `status`, `user_id`, `chat_id`, `command`, `notes`, `created_at`, `updated_at`
90 90
                 )
Please login to merge, or discard this patch.
src/Commands/AdminCommands/SendtochannelCommand.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     /**
56 56
      * Command execute method
57 57
      *
58
-     * @return \Longman\TelegramBot\Entities\ServerResponse|mixed
58
+     * @return \Longman\TelegramBot\Entities\ServerResponse
59 59
      * @throws \Longman\TelegramBot\Exception\TelegramException
60 60
      */
61 61
     public function execute()
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @todo Why send just to the first found channel?
331 331
      *
332
-     * @return mixed
332
+     * @return \Longman\TelegramBot\Entities\ServerResponse
333 333
      * @throws \Longman\TelegramBot\Exception\TelegramException
334 334
      */
335 335
     public function executeNoDb()
Please login to merge, or discard this patch.
Unused Use Statements   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@
 block discarded – undo
10 10
 
11 11
 namespace Longman\TelegramBot\Commands\AdminCommands;
12 12
 
13
-use Longman\TelegramBot\Entities\Keyboard;
14
-use Longman\TelegramBot\Request;
15
-use Longman\TelegramBot\Conversation;
16 13
 use Longman\TelegramBot\Commands\AdminCommand;
14
+use Longman\TelegramBot\Conversation;
15
+use Longman\TelegramBot\Entities\Keyboard;
17 16
 use Longman\TelegramBot\Entities\Message;
18 17
 use Longman\TelegramBot\Exception\TelegramException;
18
+use Longman\TelegramBot\Request;
19 19
 
20 20
 class SendtochannelCommand extends AdminCommand
21 21
 {
Please login to merge, or discard this patch.
src/DB.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -262,7 +262,7 @@
 block discarded – undo
262 262
         }
263 263
 
264 264
         //Convert each Entity item into an object based on its JSON reflection
265
-        $json_entities = array_map(function ($entity) {
265
+        $json_entities = array_map(function($entity) {
266 266
             return json_decode($entity, true);
267 267
         }, $entities);
268 268
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -251,7 +251,7 @@
 block discarded – undo
251 251
      * @todo Find a better way, as json_* functions are very heavy
252 252
      *
253 253
      * @param array|null $entities
254
-     * @param mixed      $default
254
+     * @param string|null      $default
255 255
      *
256 256
      * @return mixed
257 257
      */
Please login to merge, or discard this patch.
src/Request.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@
 block discarded – undo
238 238
      *
239 239
      * @param \Longman\TelegramBot\Entities\File $file
240 240
      *
241
-     * @return boolean
241
+     * @return boolean|string
242 242
      * @throws \Longman\TelegramBot\Exception\TelegramException
243 243
      */
244 244
     public static function downloadFile(File $file)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
                 'first_name' => 'botname',
261 261
                 'username'   => 'namebot',
262 262
             ];
263
-            $data['chat']       = ['id' => $data['chat_id']];
263
+            $data['chat'] = ['id' => $data['chat_id']];
264 264
 
265 265
             $fake_response['result'] = $data;
266 266
         }
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
         $multipart    = [];
285 285
 
286 286
         // Convert any nested arrays into JSON strings.
287
-        array_walk($data, function (&$item) {
287
+        array_walk($data, function(&$item) {
288 288
             is_array($item) && $item = json_encode($item);
289 289
         });
290 290
 
291 291
         //Reformat data array in multipart way if it contains a resource
292 292
         foreach ($data as $key => $item) {
293 293
             $has_resource |= (is_resource($item) || $item instanceof \GuzzleHttp\Psr7\Stream);
294
-            $multipart[]  = ['name' => $key, 'contents' => $item];
294
+            $multipart[] = ['name' => $key, 'contents' => $item];
295 295
         }
296 296
         if ($has_resource) {
297 297
             return ['multipart' => $multipart];
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                 '/bot' . self::$telegram->getApiKey() . '/' . $action,
326 326
                 $request_params
327 327
             );
328
-            $result   = (string) $response->getBody();
328
+            $result = (string) $response->getBody();
329 329
 
330 330
             //Logging getUpdates Update
331 331
             if ($action === 'getUpdates') {
@@ -651,8 +651,8 @@  discard block
 block discarded – undo
651 651
                     $requests = DB::getTelegramRequestCount($chat_id, $inline_message_id);
652 652
 
653 653
                     $chat_per_second   = ($requests['LIMIT_PER_SEC'] == 0); // No more than one message per second inside a particular chat
654
-                    $global_per_second = ($requests['LIMIT_PER_SEC_ALL'] < 30);    // No more than 30 messages per second to different chats
655
-                    $groups_per_minute = (((is_numeric($chat_id) && $chat_id > 0) || !is_null($inline_message_id)) || ((!is_numeric($chat_id) || $chat_id < 0) && $requests['LIMIT_PER_MINUTE'] < 20));    // No more than 20 messages per minute in groups and channels
654
+                    $global_per_second = ($requests['LIMIT_PER_SEC_ALL'] < 30); // No more than 30 messages per second to different chats
655
+                    $groups_per_minute = (((is_numeric($chat_id) && $chat_id > 0) || !is_null($inline_message_id)) || ((!is_numeric($chat_id) || $chat_id < 0) && $requests['LIMIT_PER_MINUTE'] < 20)); // No more than 20 messages per minute in groups and channels
656 656
 
657 657
                     if ($chat_per_second && $global_per_second && $groups_per_minute) {
658 658
                         break;
Please login to merge, or discard this patch.
src/Entities/InlineKeyboardButton.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@
 block discarded – undo
42 42
     {
43 43
         return is_array($data) &&
44 44
                array_key_exists('text', $data) && (
45
-                   array_key_exists('url', $data) ||
45
+                    array_key_exists('url', $data) ||
46 46
                    array_key_exists('callback_data', $data) ||
47 47
                    array_key_exists('switch_inline_query', $data) ||
48 48
                    array_key_exists('switch_inline_query_current_chat', $data)
49
-               );
49
+                );
50 50
     }
51 51
 
52 52
     /**
Please login to merge, or discard this patch.
src/Entities/ServerResponse.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -100,11 +100,11 @@
 block discarded – undo
100 100
 
101 101
         $result_object_types = [
102 102
             'total_count' => 'UserProfilePhotos', //Response from getUserProfilePhotos
103
-            'file_id'     => 'File',              //Response from getFile
104
-            'title'       => 'Chat',              //Response from getChat
105
-            'username'    => 'User',              //Response from getMe
106
-            'user'        => 'ChatMember',        //Response from getChatMember
107
-            'url'         => 'WebhookInfo',       //Response from getWebhookInfo
103
+            'file_id'     => 'File', //Response from getFile
104
+            'title'       => 'Chat', //Response from getChat
105
+            'username'    => 'User', //Response from getMe
106
+            'user'        => 'ChatMember', //Response from getChatMember
107
+            'url'         => 'WebhookInfo', //Response from getWebhookInfo
108 108
         ];
109 109
         foreach ($result_object_types as $type => $object_class) {
110 110
             if (isset($result[$type])) {
Please login to merge, or discard this patch.
src/Entities/Entity.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -199,8 +199,8 @@
 block discarded – undo
199 199
     public function escapeMarkdown($string)
200 200
     {
201 201
         return str_replace(
202
-            ['[', '`', '*', '_',],
203
-            ['\[', '\`', '\*', '\_',],
202
+            ['[', '`', '*', '_', ],
203
+            ['\[', '\`', '\*', '\_', ],
204 204
             $string
205 205
         );
206 206
     }
Please login to merge, or discard this patch.
src/Telegram.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -801,7 +801,7 @@
 block discarded – undo
801 801
     /**
802 802
      * Delete any assigned webhook
803 803
      *
804
-     * @return mixed
804
+     * @return ServerResponse
805 805
      * @throws \Longman\TelegramBot\Exception\TelegramException
806 806
      */
807 807
     public function deleteWebhook()
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
             throw new TelegramException('Hook url is empty!');
788 788
         }
789 789
 
790
-        $data        = array_intersect_key($data, array_flip([
790
+        $data = array_intersect_key($data, array_flip([
791 791
             'certificate',
792 792
             'max_connections',
793 793
             'allowed_updates',
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
         }
903 903
 
904 904
         $this->run_commands  = true;
905
-        $this->botan_enabled = false;   // Force disable Botan.io integration, we don't want to track self-executed commands!
905
+        $this->botan_enabled = false; // Force disable Botan.io integration, we don't want to track self-executed commands!
906 906
 
907 907
         $result = Request::getMe();
908 908
 
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
         }
920 920
 
921 921
 
922
-        $this->enableAdmin($bot_id);    // Give bot access to admin commands
923
-        $this->getCommandsList();       // Load full commands list
922
+        $this->enableAdmin($bot_id); // Give bot access to admin commands
923
+        $this->getCommandsList(); // Load full commands list
924 924
 
925 925
         foreach ($commands as $command) {
926 926
             $this->update = new Update(
Please login to merge, or discard this patch.
src/Commands/AdminCommands/CleanupCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         }
102 102
 
103 103
         // Convert numeric-only values to days.
104
-        array_walk($clean_older_than, function (&$time) use ($custom_time) {
104
+        array_walk($clean_older_than, function(&$time) use ($custom_time) {
105 105
             if (!empty($custom_time)) {
106 106
                 $time = $custom_time;
107 107
             }
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
                 }
358 358
             }
359 359
 
360
-            $pdo->commit();     // commit changes to the database and end transaction
360
+            $pdo->commit(); // commit changes to the database and end transaction
361 361
         } catch (PDOException $e) {
362
-            $pdo->rollBack();   // rollback changes on exception (useful if you want to track down error - you can't replicate it when some of the data is already deleted...)
362
+            $pdo->rollBack(); // rollback changes on exception (useful if you want to track down error - you can't replicate it when some of the data is already deleted...)
363 363
 
364 364
             $data['text'] = '*Database cleanup failed!* _(check your error logs)_';
365 365
             Request::sendMessage($data);
Please login to merge, or discard this patch.