Completed
Pull Request — master (#5)
by
unknown
01:16
created
src/Smoqadam/Keyboard/Inline.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   /**
14 14
   * Create new row.
15 15
   *
16
-  * @return object
16
+  * @return Inline
17 17
   */
18 18
   public function addRow(){
19 19
     $this->current_row++;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
   * @param string $switch_inline_query Optional. If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.
31 31
   * @param string $switch_inline_query_current_chat Optional. If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field. Can be empty, in which case only the bot’s username will be inserted.
32 32
   * @param string $callback_game Optional. Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.
33
-  * @return object
33
+  * @return Inline
34 34
   */
35 35
   public function addButton(string $text, string $url = '', string $callback_data = '', string $switch_inline_query = '', string $switch_inline_query_current_chat = '', string $callback_game = ''){
36 36
     $btn['text'] = $text;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
   *
16 16
   * @return object
17 17
   */
18
-  public function addRow(){
18
+  public function addRow() {
19 19
     $this->current_row++;
20 20
     
21 21
     return $this;
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
   * @param string $callback_game Optional. Description of the game that will be launched when the user presses the button. NOTE: This type of button must always be the first button in the first row.
33 33
   * @return object
34 34
   */
35
-  public function addButton(string $text, string $url = '', string $callback_data = '', string $switch_inline_query = '', string $switch_inline_query_current_chat = '', string $callback_game = ''){
35
+  public function addButton(string $text, string $url = '', string $callback_data = '', string $switch_inline_query = '', string $switch_inline_query_current_chat = '', string $callback_game = '') {
36 36
     $btn['text'] = $text;
37
-    if($url != '')
37
+    if ($url != '')
38 38
       $btn['url'] = $url;
39
-    elseif($callback_data != '')
39
+    elseif ($callback_data != '')
40 40
       $btn['callback_data'] = $callback_data;
41
-    elseif($switch_inline_query != '')
41
+    elseif ($switch_inline_query != '')
42 42
      $btn['switch_inline_query'] = $switch_inline_query;
43
-    elseif($switch_inline_query_current_chat != '')
43
+    elseif ($switch_inline_query_current_chat != '')
44 44
       $btn['switch_inline_query_current_chat'] = $switch_inline_query_current_chat;
45
-    elseif($callback_game != '')
45
+    elseif ($callback_game != '')
46 46
       $btn['callback_game'] = $callback_game;
47 47
     else
48 48
       $btn['callback_data'] = $text;
Please login to merge, or discard this patch.
src/Smoqadam/Telegram.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
     /**
221 221
      * execute telegram api commands
222
-     * @param $command
222
+     * @param string $command
223 223
      * @param array $params
224 224
      */
225 225
     private function exec($command, $params = []) {
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 
255 255
     /**
256 256
      * get the $url content with CURL
257
-     * @param $url
257
+     * @param string $url
258 258
      * @param $params
259
-     * @return mixed
259
+     * @return string
260 260
      */
261 261
     private function curl_get_contents($url, $params) {
262 262
         $ch = curl_init();
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     }
299 299
 
300 300
     /**
301
-     * @param null $offset
301
+     * @param integer $offset
302 302
      * @param int $limit
303 303
      * @param int $timeout
304 304
      */
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
     /**
455 455
      * send chat action : Telegram::ACTION_TYPING , ...
456
-     * @param $action
456
+     * @param string $action
457 457
      * @param null $chat_id
458 458
      */
459 459
     public function sendChatAction($action, $chat_id = null) {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         $result = $this->getUpdates();
124 124
         while (true) {
125 125
             $update_id = isset($result->update_id) ? $result->update_id : 1;
126
-            $result = $this->getUpdates($update_id + 1);
126
+            $result = $this->getUpdates($update_id+1);
127 127
 
128 128
             $this->processPayload($result);
129 129
 
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
                 $this->result = $result;
148 148
 
149 149
                 // now i select the right triggers for payload received by Telegram
150
-                if( isset($this->result->message->text) ) {
150
+                if (isset($this->result->message->text)) {
151 151
                   $payload = $this->result->message->text;
152 152
                   $triggers = $this->commands;
153
-                } elseif ( isset($this->result->inline_query) ) {
153
+                } elseif (isset($this->result->inline_query)) {
154 154
                   $payload = $this->result->inline_query->query;
155 155
                   $triggers = $this->inlines;
156
-                } else {
156
+                }else {
157 157
                   throw new \Exception("Error Processing Request", 1);
158 158
                 }
159 159
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                     //find args pattern
169 169
                     $args = $this->getArgs($pattern, $payload);
170 170
 
171
-                    $pattern = '/^' . $pattern . '/i';
171
+                    $pattern = '/^'.$pattern.'/i';
172 172
 
173 173
                     preg_match($pattern, $payload, $matches);
174 174
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
                         call_user_func($func, $args);
178 178
                     }
179 179
                 }
180
-            } catch (\Exception $e) {
180
+            }catch (\Exception $e) {
181 181
               error_log($e->getMessage());
182
-              echo "\r\n Exception :: " . $e->getMessage();
182
+              echo "\r\n Exception :: ".$e->getMessage();
183 183
             }
184
-        } else {
184
+        }else {
185 185
             echo "\r\nNo new message\r\n";
186 186
         }
187 187
     }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             $tmp_args_pattern = str_replace(['<<', '>>'], ['(', ')'], $pattern);
203 203
 
204 204
             //if args set
205
-            if (preg_match('/' . $tmp_args_pattern . '/i', $payload, $matches)) {
205
+            if (preg_match('/'.$tmp_args_pattern.'/i', $payload, $matches)) {
206 206
                 //remove first element
207 207
                 array_shift($matches);
208 208
                 if (isset($matches[0])) {
@@ -225,16 +225,16 @@  discard block
 block discarded – undo
225 225
     private function exec($command, $params = []) {
226 226
         if (in_array($command, $this->available_commands)) {
227 227
           // convert json to array then get the last messages info
228
-          $output = json_decode($this->curl_get_contents($this->api . '/' . $command, $params), true);
228
+          $output = json_decode($this->curl_get_contents($this->api.'/'.$command, $params), true);
229 229
 
230 230
         	return $this->convertToObject($output);
231
-        } else {
231
+        }else {
232 232
             echo 'command not found';
233 233
         }
234 234
     }
235 235
 
236
-    private function convertToObject($jsonObject , $webhook = false) {
237
-      if( ! $webhook) {
236
+    private function convertToObject($jsonObject, $webhook = false) {
237
+      if (!$webhook) {
238 238
         if ($jsonObject['ok']) {
239 239
           //error_log(print_r($jsonObject, true));
240 240
 
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
           $output = end($jsonObject);
243 243
 
244 244
           $result = is_array($output) ? end($output) : $output;
245
-          if ( ! empty($result)) {
245
+          if (!empty($result)) {
246 246
               // convert to object
247 247
               return json_decode(json_encode($result));
248 248
           }
249 249
         }
250
-      } else {
250
+      }else {
251 251
         return json_decode(json_encode($jsonObject));
252 252
       }
253 253
     }
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
         if ($chat_id)
286 286
           return $chat_id;
287 287
 
288
-        if( isset($this->result->message) ) {
288
+        if (isset($this->result->message)) {
289 289
           return $this->result->message->chat->id;
290
-        } elseif ( isset($this->result->inline_query) ) {
290
+        } elseif (isset($this->result->inline_query)) {
291 291
           return $this->result->inline_query->from->id;
292
-        } else {
292
+        }else {
293 293
           throw new \Exception("Error Processing Request", 1);
294 294
         }
295
-      } catch (\Exception $e) {
295
+      }catch (\Exception $e) {
296 296
         error_log($e->getMessage());
297 297
       }
298 298
     }
Please login to merge, or discard this patch.
src/Smoqadam/InlineQuery/Result/Article.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
   public function __construct($title, $content) {
14 14
     $this->title = $title;
15 15
     $this->input_message_content = $content;
16
-    $this->id = '' . rand();
16
+    $this->id = ''.rand();
17 17
   }
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/Smoqadam/Keyboard/Standard.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
   *
25 25
   * @return object Standard
26 26
   */
27
-  public function addRow(){
27
+  public function addRow() {
28 28
     $this->current_row++;
29 29
     
30 30
     return $this;
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
   * @param boolean $request_location Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only
39 39
   * @return object
40 40
   */
41
-  public function addButton(string $text, boolean $request_contact = null, boolean $request_location = null){
41
+  public function addButton(string $text, boolean $request_contact = null, boolean $request_location = null) {
42 42
     $this->keyboard[$this->current_row][] = [
43 43
       'text' => $text,
44 44
       'request_contact' => ($request_contact != null) ? $request_contact : false,
Please login to merge, or discard this patch.
src/Smoqadam/Keyboard/Remove.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
     *
14 14
     * @param boolean $selective Optional. Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot's message is a reply (has reply_to_message_id), sender of the original message.
15 15
     */
16
-    public function __construct($selective = false){
17
-        $this->selective        = $selective;
16
+    public function __construct($selective = false) {
17
+        $this->selective = $selective;
18 18
     }
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@
 block discarded – undo
7 7
 
8 8
 $tg = new Telegram('API_TOKEN');
9 9
 
10
-$tg->cmd('name:<<[a-zA-Z]{0,}>>', function ($args) use ($tg){
10
+$tg->cmd('name:<<[a-zA-Z]{0,}>>', function($args) use ($tg){
11 11
 	
12
-		$tg->sendMessage("my username is @".$args , $tg->getChatId());
12
+		$tg->sendMessage("my username is @".$args, $tg->getChatId());
13 13
 });
14 14
 
15 15
 
16
-$tg->cmd('<<:any>>',function ($arg) use ($tg){
17
-	$tg->sendMessage("You Message is : " . $arg, $tg->getChatId()); 
16
+$tg->cmd('<<:any>>', function($arg) use ($tg){
17
+	$tg->sendMessage("You Message is : ".$arg, $tg->getChatId()); 
18 18
 });
19 19
 
20 20
 $tg->run();
Please login to merge, or discard this patch.