Passed
Push — main ( 0084f7...f34b86 )
by Miaad
12:18
created
src/types/switchInlineQueryChosenChat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
     public bool $allow_channel_chats;
32 32
 
33 33
 
34
-    public function __construct(stdClass|null $object = null) {
34
+    public function __construct(stdClass | null $object = null) {
35 35
         if ($object != null) {
36 36
             parent::__construct($object, self::subs);
37 37
         }
Please login to merge, or discard this patch.
src/types/writeAccessAllowed.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     /** Optional. Name of the Web App which was launched from a link */
16 16
     public string $web_app_name;
17 17
 
18
-    public function __construct(stdClass|null $object = null) {
18
+    public function __construct(stdClass | null $object = null) {
19 19
         if ($object != null) {
20 20
             parent::__construct($object, self::subs);
21 21
         }
Please login to merge, or discard this patch.
src/types/inputSticker.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      * under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL. More information on
20 20
      * Sending Files »
21 21
      */
22
-    public string|CURLFile $sticker;
22
+    public string | CURLFile $sticker;
23 23
 
24 24
     /**
25 25
      * List of 1-20 emoji associated with the sticker
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public array $keywords;
39 39
 
40 40
 
41
-    public function __construct(stdClass|null $object = null) {
41
+    public function __construct(stdClass | null $object = null) {
42 42
         if ($object != null) {
43 43
             parent::__construct($object, self::subs);
44 44
         }
Please login to merge, or discard this patch.
src/types/inlineQueryResultsButton.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
     public string $start_parameter;
34 34
 
35 35
 
36
-    public function __construct(stdClass|null $object = null) {
36
+    public function __construct(stdClass | null $object = null) {
37 37
         if ($object != null) {
38 38
             parent::__construct($object, self::subs);
39 39
         }
Please login to merge, or discard this patch.
src/types/botName.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
     public string $name;
16 16
 
17 17
 
18
-    public function __construct(stdClass|null $object = null) {
18
+    public function __construct(stdClass | null $object = null) {
19 19
         if ($object != null) {
20 20
             parent::__construct($object, self::subs);
21 21
         }
Please login to merge, or discard this patch.
src/external/jdf.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @Version: 2.76 =>[ 1399/11/28 = 1442/07/04 = 2021/02/16 ]
11 11
  */
12 12
 class jdf {
13
-    public static function jdate ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
13
+    public static function jdate($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
14 14
         $T_sec = 0;
15 15
         if ($time_zone != 'local') {
16 16
             date_default_timezone_set(empty($time_zone) ? 'Asia/Tehran' : $time_zone);
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
                     $output .= (int) ($jalali_month / 3.1) + 1;
57 57
                     break;
58 58
                 case 'c':
59
-                    $output .= $jalali_year . '/' . $jalali_month . '/' . $jalali_day . ' ،' . $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[5];
59
+                    $output .= $jalali_year.'/'.$jalali_month.'/'.$jalali_day.' ،'.$date[0].':'.$date[1].':'.$date[6].' '.$date[5];
60 60
                     break;
61 61
                 case 'C':
62 62
                     $output .= (int) (($jalali_year + 99) / 100);
63 63
                     break;
64 64
                 case 'd':
65
-                    $output .= $jalali_day < 10 ? '0' . $jalali_day : $jalali_day;
65
+                    $output .= $jalali_day < 10 ? '0'.$jalali_day : $jalali_day;
66 66
                     break;
67 67
                 case 'D':
68 68
                     $output .= self::jdate_words(['kh' => $date[7]], ' ');
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
                     $output .= $leap_year;
99 99
                     break;
100 100
                 case 'm':
101
-                    $output .= $jalali_month > 9 ? $jalali_month : '0' . $jalali_month;
101
+                    $output .= $jalali_month > 9 ? $jalali_month : '0'.$jalali_month;
102 102
                     break;
103 103
                 case 'M':
104 104
                     $output .= self::jdate_words(['km' => $jalali_month], ' ');
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     break;
132 132
                 case 'r':
133 133
                     $key = self::jdate_words(['rh' => $date[7], 'mm' => $jalali_month]);
134
-                    $output .= $date[0] . ':' . $date[1] . ':' . $date[6] . ' ' . $date[4] . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year;
134
+                    $output .= $date[0].':'.$date[1].':'.$date[6].' '.$date[4].' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year;
135 135
                     break;
136 136
                 case 's':
137 137
                     $output .= $date[6];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
                     if ($aks == 7) {
169 169
                         $aks = 0;
170 170
                     }
171
-                    $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0' . $num : $num);
171
+                    $output .= ($leap_year + 363 - $doy < $aks and $aks < 3) ? '01' : ($num < 10 ? '0'.$num : $num);
172 172
                     break;
173 173
                 case 'y':
174 174
                     $output .= substr($jalali_year, 2, 2);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
         }
186 186
         return $tr_num != 'en' ? self::tr_num($output, 'fa', '.') : $output;
187 187
     }
188
-    public static function jstrftime ($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
189
-        $T_sec = 0;/* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
188
+    public static function jstrftime($format, $timestamp = '', $none = '', $time_zone = 'Asia/Tehran', $tr_num = 'fa') {
189
+        $T_sec = 0; /* <= رفع خطاي زمان سرور ، با اعداد '+' و '-' بر حسب ثانيه */
190 190
         if ($time_zone != 'local') date_default_timezone_set(($time_zone === '') ? 'Asia/Tehran' : $time_zone);
191 191
         $timestamp = $T_sec + (($timestamp === '') ? time() : self::tr_num($timestamp));
192 192
         $date = explode('_', date('h_H_i_j_n_s_w_Y', $timestamp));
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
                     $output .= self::jdate_words(['rh' => $date[6]], ' ');
214 214
                     break;
215 215
                 case 'd':
216
-                    $output .= ($jalali_day < 10) ? '0' . $jalali_day : $jalali_day;
216
+                    $output .= ($jalali_day < 10) ? '0'.$jalali_day : $jalali_day;
217 217
                     break;
218 218
                 case 'e':
219
-                    $output .= ($jalali_day < 10) ? ' ' . $jalali_day : $jalali_day;
219
+                    $output .= ($jalali_day < 10) ? ' '.$jalali_day : $jalali_day;
220 220
                     break;
221 221
                 case 'j':
222 222
                     $output .= str_pad($doy + 1, 3, 0, STR_PAD_LEFT);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                 if ($avs < 0) $avs += 7;
233 233
                 $num = (int) (($doy + $avs) / 7) + 1;
234 234
                 if ($avs > 3 or $avs == 1) $num--;
235
-                $output .= ($num < 10) ? '0' . $num : $num;
235
+                $output .= ($num < 10) ? '0'.$num : $num;
236 236
                 break;
237 237
                 case 'V':
238 238
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
@@ -246,14 +246,14 @@  discard block
 block discarded – undo
246 246
                     }
247 247
                     $aks = $avs + $leap_year;
248 248
                     if ($aks == 7) $aks = 0;
249
-                    $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0' . $num : $num);
249
+                    $output .= (($leap_year + 363 - $doy) < $aks and $aks < 3) ? '01' : (($num < 10) ? '0'.$num : $num);
250 250
                     break;
251 251
                 case 'W':
252 252
                     $avs = (($date[6] == 6) ? 0 : $date[6] + 1) - ($doy % 7);
253 253
                     if ($avs < 0) $avs += 7;
254 254
                     $num = (int) (($doy + $avs) / 7) + 1;
255 255
                     if ($avs > 3) $num--;
256
-                    $output .= ($num < 10) ? '0' . $num : $num;
256
+                    $output .= ($num < 10) ? '0'.$num : $num;
257 257
                     break;
258 258
                 /* Month */ case 'b':
259 259
                 case 'h':
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
                     $output .= self::jdate_words(['mm' => $jalali_month], ' ');
264 264
                     break;
265 265
                 case 'm':
266
-                    $output .= ($jalali_month > 9) ? $jalali_month : '0' . $jalali_month;
266
+                    $output .= ($jalali_month > 9) ? $jalali_month : '0'.$jalali_month;
267 267
                     break;
268 268
                 /* Year */ case 'C':
269 269
                 $tmp = (int) ($jalali_year / 100);
270
-                $output .= ($tmp > 9) ? $tmp : '0' . $tmp;
270
+                $output .= ($tmp > 9) ? $tmp : '0'.$tmp;
271 271
                 break;
272 272
                 case 'g':
273 273
                     $jdw = ($date[6] == 6) ? 0 : $date[6] + 1;
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                     $output .= $date[0];
293 293
                     break;
294 294
                 case 'l':
295
-                    $output .= ($date[0] > 9) ? $date[0] : ' ' . (int) $date[0];
295
+                    $output .= ($date[0] > 9) ? $date[0] : ' '.(int) $date[0];
296 296
                     break;
297 297
                 case 'M':
298 298
                     $output .= $date[2];
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
                     $output .= ($date[1] < 12) ? 'ق.ظ' : 'ب.ظ';
305 305
                     break;
306 306
                 case 'r':
307
-                    $output .= $date[0] . ':' . $date[2] . ':' . $date[5] . ' ' . (($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر');
307
+                    $output .= $date[0].':'.$date[2].':'.$date[5].' '.(($date[1] < 12) ? 'قبل از ظهر' : 'بعد از ظهر');
308 308
                     break;
309 309
                 case 'R':
310
-                    $output .= $date[1] . ':' . $date[2];
310
+                    $output .= $date[1].':'.$date[2];
311 311
                     break;
312 312
                 case 'S':
313 313
                     $output .= $date[5];
314 314
                     break;
315 315
                 case 'T':
316
-                    $output .= $date[1] . ':' . $date[2] . ':' . $date[5];
316
+                    $output .= $date[1].':'.$date[2].':'.$date[5];
317 317
                     break;
318 318
                 case 'X':
319
-                    $output .= $date[0] . ':' . $date[2] . ':' . $date[5];
319
+                    $output .= $date[0].':'.$date[2].':'.$date[5];
320 320
                     break;
321 321
                 case 'z':
322 322
                     $output .= date('O', $timestamp);
@@ -326,19 +326,19 @@  discard block
 block discarded – undo
326 326
                     break;
327 327
                 /* Time and Date Stamps */ case 'c':
328 328
                 $key = self::jdate_words(['rh' => $date[6], 'mm' => $jalali_month]);
329
-                $output .= $date[1] . ':' . $date[2] . ':' . $date[5] . ' ' . date('P', $timestamp) . ' ' . $key['rh'] . '، ' . $jalali_day . ' ' . $key['mm'] . ' ' . $jalali_year;
329
+                $output .= $date[1].':'.$date[2].':'.$date[5].' '.date('P', $timestamp).' '.$key['rh'].'، '.$jalali_day.' '.$key['mm'].' '.$jalali_year;
330 330
                 break;
331 331
                 case 'D':
332
-                    $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
332
+                    $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
333 333
                     break;
334 334
                 case 'F':
335
-                    $output .= $jalali_year . '-' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '-' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
335
+                    $output .= $jalali_year.'-'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'-'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
336 336
                     break;
337 337
                 case 's':
338 338
                     $output .= $timestamp;
339 339
                     break;
340 340
                 case 'x':
341
-                    $output .= substr($jalali_year, 2, 2) . '/' . (($jalali_month > 9) ? $jalali_month : '0' . $jalali_month) . '/' . (($jalali_day < 10) ? '0' . $jalali_day : $jalali_day);
341
+                    $output .= substr($jalali_year, 2, 2).'/'.(($jalali_month > 9) ? $jalali_month : '0'.$jalali_month).'/'.(($jalali_day < 10) ? '0'.$jalali_day : $jalali_day);
342 342
                     break;
343 343
                 /* Miscellaneous */ case 'n':
344 344
                 $output .= "\n";
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         }
356 356
         return ($tr_num != 'en') ? self::tr_num($output, 'fa', '.') : $output;
357 357
     }
358
-    public static function jmktime ($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool|int {
358
+    public static function jmktime($hour = '', $minute = '', $second = '', $jalali_month = '', $jalali_day = '', $jalali_year = '', $none = '', $timezone = 'Asia/Tehran'): bool | int {
359 359
         if ($timezone != 'local') date_default_timezone_set($timezone);
360 360
         if ($hour === '') {
361 361
             return time();
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 $jalali_month,
369 369
                 $jalali_day,
370 370
                 $jalali_year
371
-            ] = explode('_', self::tr_num($hour . '_' . $minute . '_' . $second . '_' . $jalali_month . '_' . $jalali_day . '_' . $jalali_year));
371
+            ] = explode('_', self::tr_num($hour.'_'.$minute.'_'.$second.'_'.$jalali_month.'_'.$jalali_day.'_'.$jalali_year));
372 372
             if ($minute === '') {
373 373
                 return mktime($hour);
374 374
             }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
             }
414 414
         }
415 415
     }
416
-    public static function jgetdate ($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') {
416
+    public static function jgetdate($timestamp = '', $none = '', $timezone = 'Asia/Tehran', $tn = 'en') {
417 417
         $timestamp = ($timestamp === '') ? time() : self::tr_num($timestamp);
418 418
         $jdate = explode('_', self::jdate('F_G_i_j_l_n_s_w_Y_z', $timestamp, '', $timezone, $tn));
419 419
         return [
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
             0         => self::tr_num($timestamp, $tn)
431 431
         ];
432 432
     }
433
-    public static function jcheckdate ($jalali_month, $jalali_day, $jalali_year): bool {
434
-        [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month . '_' . $jalali_day . '_' . $jalali_year));
433
+    public static function jcheckdate($jalali_month, $jalali_day, $jalali_year): bool {
434
+        [$jalali_month, $jalali_day, $jalali_year] = explode('_', self::tr_num($jalali_month.'_'.$jalali_day.'_'.$jalali_year));
435 435
         $l_d = ($jalali_month == 12 and ($jalali_year + 12) % 33 % 4 != 1) ? 29 : 31 - (int) ($jalali_month / 6.5);
436 436
         return !(($jalali_month > 12 or $jalali_day > $l_d or $jalali_month < 1 or $jalali_day < 1 or $jalali_year < 1));
437 437
     }
438
-    public static function tr_num ($string, $mod = 'en', $mf = '٫'): array|string {
438
+    public static function tr_num($string, $mod = 'en', $mf = '٫'): array | string {
439 439
         $english_number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'];
440 440
         $persian_number = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', $mf];
441 441
         return $mod == 'fa' ? str_replace($english_number, $persian_number, $string) : str_replace($persian_number, $english_number, $string);
442 442
     }
443
-    public static function jdate_words ($array, $splitter = '') {
443
+    public static function jdate_words($array, $splitter = '') {
444 444
         foreach ($array as $type => $num) {
445 445
             $num = (int) self::tr_num($num);
446 446
             switch ($type) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
                                 'هزار و چهارصد',
479 479
                                 'هزار و نهصد',
480 480
                                 'دوهزار'
481
-                            ], substr($num, 0, 2)) . (substr($num, 2, 2) == '00' ? '' : ' و ') : '') . $h3 . $p34 . $h34 . $h4;
481
+                            ], substr($num, 0, 2)).(substr($num, 2, 2) == '00' ? '' : ' و ') : '').$h3.$p34.$h34.$h4;
482 482
                     break;
483 483
                 case 'mm':
484 484
                     $array[$type] = [
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
         }
595 595
         return $splitter === '' ? $array : implode($splitter, $array);
596 596
     }
597
-    public static function gregorian_to_jalali ($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array|string {
598
-        [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year . '_' . $gregorian_month . '_' . $gregorian_day));/* <= Extra :اين سطر ، جزء تابع اصلي نيست */
597
+    public static function gregorian_to_jalali($gregorian_year, $gregorian_month, $gregorian_day, $splitter = ''): array | string {
598
+        [$gregorian_year, $gregorian_month, $gregorian_day] = explode('_', self::tr_num($gregorian_year.'_'.$gregorian_month.'_'.$gregorian_day)); /* <= Extra :اين سطر ، جزء تابع اصلي نيست */
599 599
         $g_d_m = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
600 600
         $gregorian_year2 = ($gregorian_month > 2) ? ($gregorian_year + 1) : $gregorian_year;
601 601
         $days = 355666 + (365 * $gregorian_year) + ((int) (($gregorian_year2 + 3) / 4)) - ((int) (($gregorian_year2 + 99) / 100)) + ((int) (($gregorian_year2 + 399) / 400)) + $gregorian_day + $g_d_m[$gregorian_month - 1];
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
             $jalali_month = 7 + (int) (($days - 186) / 30);
616 616
             $jalali_day = 1 + (($days - 186) % 30);
617 617
         }
618
-        return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year . $splitter . $jalali_month . $splitter . $jalali_day;
618
+        return $splitter == '' ? [$jalali_year, $jalali_month, $jalali_day] : $jalali_year.$splitter.$jalali_month.$splitter.$jalali_day;
619 619
     }
620
-    public static function jalali_to_gregorian ($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array|string {
621
-        [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year . '_' . $jalali_month . '_' . $jalali_day));
620
+    public static function jalali_to_gregorian($jalali_year, $jalali_month, $jalali_day, $splitter = ''): array | string {
621
+        [$jalali_year, $jalali_month, $jalali_day] = explode('_', self::tr_num($jalali_year.'_'.$jalali_month.'_'.$jalali_day));
622 622
         $jalali_year += 1595;
623 623
         $days = -355668 + (365 * $jalali_year) + (((int) ($jalali_year / 33)) * 8) + ((int) ((($jalali_year % 33) + 3) / 4)) + $jalali_day + (($jalali_month < 7) ? ($jalali_month - 1) * 31 : (($jalali_month - 7) * 30) + 186);
624 624
         $gregorian_year = 400 * (int) ($days / 146097);
@@ -655,6 +655,6 @@  discard block
 block discarded – undo
655 655
         for ($gregorian_month = 0; $gregorian_month < 13 and $gregorian_day > $month_days[$gregorian_month]; $gregorian_month++) {
656 656
             $gregorian_day -= $month_days[$gregorian_month];
657 657
         }
658
-        return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year . $splitter . $gregorian_month . $splitter . $gregorian_day;
658
+        return $splitter == '' ? [$gregorian_year, $gregorian_month, $gregorian_day] : $gregorian_year.$splitter.$gregorian_month.$splitter.$gregorian_day;
659 659
     }
660 660
 }
661 661
\ No newline at end of file
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,6 +49,6 @@
 block discarded – undo
49 49
  *
50 50
  * @return array|string
51 51
  */
52
-function strReplace(array $replacements, string|array $subject): array|string {
52
+function strReplace(array $replacements, string | array $subject): array | string {
53 53
     return str_replace(array_keys($replacements), array_values($replacements), $subject);
54 54
 }
55 55
\ No newline at end of file
Please login to merge, or discard this patch.
examples/messenger/bot.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     const ADMIN = 123456789;
20 20
     const SHOW_STATUS = true;
21 21
     const UNKNOWN = 'I didnt understand it, Please use commands or reply to a user message';
22
-    const HELP            = 'Hello dear admin 
22
+    const HELP = 'Hello dear admin 
23 23
 This is a simple messenger bot which also support reply for users and admin itself
24 24
 For answering an user message , You must reply on it
25 25
 If you want to reply , You must first use /reply_on command and this will apply on your next message
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
     const SEND_FAILED     = 'Failed!';
35 35
     const SEND_SUCCESSFUL = 'Done!';
36 36
 
37
-    public function __construct (array $settings) {
37
+    public function __construct(array $settings) {
38 38
         parent::__construct($settings);
39 39
     }
40 40
 
41
-    public function message (message $update) {
41
+    public function message(message $update) {
42 42
         $text = $update->text ?? '';
43 43
         $user_id = $update->from->id;
44 44
 
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
                 return $this->sendMessage(self::HELP, answer: true);
55 55
             }
56 56
             if ($text === '/reply_on') {
57
-                mysql::update('users',['value'=>'reply_on'],['id'=>$user_id],1);
57
+                mysql::update('users', ['value'=>'reply_on'], ['id'=>$user_id], 1);
58 58
                 return $this->sendMessage(self::REPLY_ON, answer: true);
59 59
             }
60 60
             if ($text === '/reply_off') {
61
-                mysql::update('users',['value'=>'reply_off'],['id'=>$user_id],1);
61
+                mysql::update('users', ['value'=>'reply_off'], ['id'=>$user_id], 1);
62 62
                 return $this->sendMessage(self::REPLY_OFF, answer: true);
63 63
             }
64 64
             if (!isset($update->reply_to_message)) {
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
             $reply_message_id = $update->reply_to_message->message_id;
69 69
 
70 70
             if ($update->reply_to_message->from->id === $user_id) {
71
-                $check_message = mysql::select('messages', ['receiver_message_id','receiver_id'], [
71
+                $check_message = mysql::select('messages', ['receiver_message_id', 'receiver_id'], [
72 72
                     'sender_message_id' => $reply_message_id,
73 73
                     'sender_id'         => $user_id
74
-                ],1);
74
+                ], 1);
75 75
 
76 76
                 if ($check_message->num_rows < 1) {
77 77
                     return $this->sendMessage(self::NOT_FOUND, answer: true);
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
                 $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->receiver_message_id);
82 82
             }
83 83
             else {
84
-                $check_message = mysql::select('messages', ['sender_message_id','sender_id'], [
84
+                $check_message = mysql::select('messages', ['sender_message_id', 'sender_id'], [
85 85
                     'receiver_message_id' => $reply_message_id,
86 86
                     'receiver_id'         => $user_id
87
-                ],1);
87
+                ], 1);
88 88
 
89 89
                 if ($check_message->num_rows < 1) {
90 90
                     return $this->sendMessage(self::NOT_FOUND, answer: true);
91 91
                 }
92 92
                 $data = $check_message->fetch_object();
93
-                $value = mysql::select('users','value',['id'=>$user_id])->fetch_object()->value;
93
+                $value = mysql::select('users', 'value', ['id'=>$user_id])->fetch_object()->value;
94 94
                 $receiver_id = $data->sender_id;
95 95
                 if ($value === 'reply_on') {
96
-                    mysql::update('users',['value'=>''],['id'=>$user_id]);
96
+                    mysql::update('users', ['value'=>''], ['id'=>$user_id]);
97 97
                     $result = $this->copyMessage($receiver_id, reply_to_message_id: $data->sender_message_id);
98 98
                 }
99 99
                 else {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         }
118 118
         $username = $update->from->username;
119 119
         if (empty($username)) {
120
-            $name = $update->from->first_name . (!empty($update->from->last_name) ? (' ' . $update->from->last_name) : '');
120
+            $name = $update->from->first_name.(!empty($update->from->last_name) ? (' '.$update->from->last_name) : '');
121 121
             $keyboard = [
122 122
                 'inline_keyboard' => [
123 123
                     [
@@ -155,33 +155,33 @@  discard block
 block discarded – undo
155 155
         }
156 156
         if (isset($update->reply_to_message)) {
157 157
             $reply_message_id = $update->reply_to_message->message_id;
158
-            if ($update->reply_to_message->from->id === $user_id){
158
+            if ($update->reply_to_message->from->id === $user_id) {
159 159
                 $check_message = mysql::select('messages', 'receiver_message_id', [
160 160
                     'sender_message_id' => $reply_message_id,
161 161
                     'sender_id'         => $user_id
162
-                ],1);
162
+                ], 1);
163 163
                 if ($check_message->num_rows > 0) {
164
-                    $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id,reply_markup: $keyboard);
164
+                    $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->receiver_message_id, reply_markup: $keyboard);
165 165
                 }
166 166
                 else {
167
-                    $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
167
+                    $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
168 168
                 }
169 169
             }
170 170
             else {
171 171
                 $check_message = mysql::select('messages', 'sender_message_id', [
172 172
                     'receiver_message_id' => $reply_message_id,
173 173
                     'receiver_id'         => $user_id
174
-                ],1);
174
+                ], 1);
175 175
                 if ($check_message->num_rows > 0) {
176
-                    $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id,reply_markup: $keyboard);
176
+                    $result = $this->copyMessage(self::ADMIN, reply_to_message_id: $check_message->fetch_object()->sender_message_id, reply_markup: $keyboard);
177 177
                 }
178 178
                 else {
179
-                    $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
179
+                    $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
180 180
                 }
181 181
             }
182 182
         }
183 183
         else {
184
-            $result = $this->copyMessage(self::ADMIN,reply_markup: $keyboard);
184
+            $result = $this->copyMessage(self::ADMIN, reply_markup: $keyboard);
185 185
         }
186 186
 
187 187
         /**
Please login to merge, or discard this patch.
src/tools/cpanel.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -22,30 +22,30 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @return void
24 24
      */
25
-    public static function init (string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void {
25
+    public static function init(string $cpanelUser, string $cpanelPassword, string $cpanelUrl = '127.0.0.1', int $cpanelPort = 2083): void {
26 26
         self::$cpanelUser = $cpanelUser;
27 27
         self::$cpanelPassword = $cpanelPassword;
28 28
         self::$cpanelUrl = $cpanelUrl;
29 29
         self::$cpanelPort = $cpanelPort;
30 30
     }
31 31
 
32
-    private static function createCurl () {
32
+    private static function createCurl() {
33 33
         $curl = curl_init();
34 34
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
35 35
         curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
36 36
         curl_setopt($curl, CURLOPT_HEADER, 0);
37 37
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
38
-        $header[0] = 'Authorization: Basic ' . base64_encode(self::$cpanelUser . ':' . self::$cpanelPassword) . "\n\r";
38
+        $header[0] = 'Authorization: Basic '.base64_encode(self::$cpanelUser.':'.self::$cpanelPassword)."\n\r";
39 39
         curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
40 40
         return $curl;
41 41
     }
42 42
 
43
-    private static function execute (string $query = ''): bool|stdClass|array {
43
+    private static function execute(string $query = ''): bool | stdClass | array {
44 44
         $curl = self::createCurl();
45
-        curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/execute/' . $query);
45
+        curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/execute/'.$query);
46 46
         $result = curl_exec($curl);
47 47
         if (!$result) {
48
-            error_log('curl_exec threw error `' . curl_error($curl) . "` for $query");
48
+            error_log('curl_exec threw error `'.curl_error($curl)."` for $query");
49 49
         }
50 50
         curl_close($curl);
51 51
         $result = json_decode($result);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         return $result->data ?? true;
56 56
     }
57 57
 
58
-    private static function executev2 (string $module, string $function, array $vars = []) {
58
+    private static function executev2(string $module, string $function, array $vars = []) {
59 59
         $curl = self::createCurl();
60 60
         $vars = array_merge([
61 61
             'cpanel_jsonapi_user'       => 'user',
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
             'cpanel_jsonapi_module'     => $module,
64 64
             'cpanel_jsonapi_func'       => $function,
65 65
         ], $vars);
66
-        curl_setopt($curl, CURLOPT_URL, 'https://' . self::$cpanelUrl . ':' . self::$cpanelPort . '/json-api/cpanel?' . http_build_query($vars));
66
+        curl_setopt($curl, CURLOPT_URL, 'https://'.self::$cpanelUrl.':'.self::$cpanelPort.'/json-api/cpanel?'.http_build_query($vars));
67 67
         $result = curl_exec($curl);
68 68
         if (!$result) {
69
-            error_log('curl_exec threw error `' . curl_error($curl) . '` for ' . json_encode($vars));
69
+            error_log('curl_exec threw error `'.curl_error($curl).'` for '.json_encode($vars));
70 70
         }
71 71
         curl_close($curl);
72 72
         return $result;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      *
81 81
      * @return array
82 82
      */
83
-    public static function mysqlWizard (string $database, string $user, string $password, array $privileges = []): array {
83
+    public static function mysqlWizard(string $database, string $user, string $password, array $privileges = []): array {
84 84
         $create_database = self::createMysqlDatabase($database);
85 85
         $create_user = self::createMysqlUser($user, $password);
86 86
         if (empty($privileges)) {
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return bool|array|stdClass
103 103
      */
104
-    public static function createMysqlDatabase (string $database): bool|array|stdClass {
104
+    public static function createMysqlDatabase(string $database): bool | array | stdClass {
105 105
         if (!str_starts_with($database, self::$cpanelUser)) {
106
-            $database = self::$cpanelUser . '_' . $database;
106
+            $database = self::$cpanelUser.'_'.$database;
107 107
         }
108 108
         return self::execute("Mysql/create_database?name=$database");
109 109
     }
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return bool|array|stdClass
115 115
      */
116
-    public static function deleteMysqlDatabase (string $database): bool|array|stdClass {
116
+    public static function deleteMysqlDatabase(string $database): bool | array | stdClass {
117 117
         if (!str_starts_with($database, self::$cpanelUser)) {
118
-            $database = self::$cpanelUser . '_' . $database;
118
+            $database = self::$cpanelUser.'_'.$database;
119 119
         }
120 120
         return self::execute("Mysql/delete_database?name=$database");
121 121
     }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
      *
127 127
      * @return bool|array|stdClass
128 128
      */
129
-    public static function createMysqlUser (string $user, string $password): bool|array|stdClass {
129
+    public static function createMysqlUser(string $user, string $password): bool | array | stdClass {
130 130
         if (!str_starts_with($user, self::$cpanelUser)) {
131
-            $user = self::$cpanelUser . '_' . $user;
131
+            $user = self::$cpanelUser.'_'.$user;
132 132
         }
133 133
         return self::execute("Mysql/create_user?name=$user&password=$password");
134 134
     }
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
      *
139 139
      * @return bool|array|stdClass
140 140
      */
141
-    public static function deleteMysqlUser (string $user): bool|array|stdClass {
141
+    public static function deleteMysqlUser(string $user): bool | array | stdClass {
142 142
         if (!str_starts_with($user, self::$cpanelUser)) {
143
-            $user = self::$cpanelUser . '_' . $user;
143
+            $user = self::$cpanelUser.'_'.$user;
144 144
         }
145 145
         return self::execute("Mysql/delete_user?name=$user");
146 146
     }
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
      *
153 153
      * @return bool|array|stdClass
154 154
      */
155
-    public static function setMysqlPrivileges (string $database, string $user, array $privileges): bool|array|stdClass {
155
+    public static function setMysqlPrivileges(string $database, string $user, array $privileges): bool | array | stdClass {
156 156
         if (!str_starts_with($database, self::$cpanelUser)) {
157
-            $database = self::$cpanelUser . '_' . $database;
157
+            $database = self::$cpanelUser.'_'.$database;
158 158
         }
159 159
         if (!str_starts_with($user, self::$cpanelUser)) {
160
-            $user = self::$cpanelUser . '_' . $user;
160
+            $user = self::$cpanelUser.'_'.$user;
161 161
         }
162 162
         $all_privileges = [
163 163
             'ALTER',
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
      *
194 194
      * @return bool|array|stdClass
195 195
      */
196
-    public static function setMysqlPrivilegesAll (string $database, string $user): bool|array|stdClass {
196
+    public static function setMysqlPrivilegesAll(string $database, string $user): bool | array | stdClass {
197 197
         if (!str_starts_with($database, self::$cpanelUser)) {
198
-            $database = self::$cpanelUser . '_' . $database;
198
+            $database = self::$cpanelUser.'_'.$database;
199 199
         }
200 200
         if (!str_starts_with($user, self::$cpanelUser)) {
201
-            $user = self::$cpanelUser . '_' . $user;
201
+            $user = self::$cpanelUser.'_'.$user;
202 202
         }
203 203
         return self::execute("Mysql/set_privileges_on_database?user=$user&database=$database&privileges=ALL");
204 204
     }
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
      *
210 210
      * @return bool|array|stdClass
211 211
      */
212
-    public static function changeMysqlDatabaseName (string $old_name, string $new_name): bool|array|stdClass {
212
+    public static function changeMysqlDatabaseName(string $old_name, string $new_name): bool | array | stdClass {
213 213
         if (!str_starts_with($old_name, self::$cpanelUser)) {
214
-            $old_name = self::$cpanelUser . '_' . $old_name;
214
+            $old_name = self::$cpanelUser.'_'.$old_name;
215 215
         }
216 216
         if (!str_starts_with($new_name, self::$cpanelUser)) {
217
-            $new_name = self::$cpanelUser . '_' . $new_name;
217
+            $new_name = self::$cpanelUser.'_'.$new_name;
218 218
         }
219 219
         return self::execute("Mysql/rename_database?oldname=$old_name&newname=$new_name");
220 220
     }
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
      *
226 226
      * @return bool|array|stdClass
227 227
      */
228
-    public static function changeMysqlUserName (string $old_name, string $new_name): bool|array|stdClass {
228
+    public static function changeMysqlUserName(string $old_name, string $new_name): bool | array | stdClass {
229 229
         if (!str_starts_with($old_name, self::$cpanelUser)) {
230
-            $old_name = self::$cpanelUser . '_' . $old_name;
230
+            $old_name = self::$cpanelUser.'_'.$old_name;
231 231
         }
232 232
         if (!str_starts_with($new_name, self::$cpanelUser)) {
233
-            $new_name = self::$cpanelUser . '_' . $new_name;
233
+            $new_name = self::$cpanelUser.'_'.$new_name;
234 234
         }
235 235
         return self::execute("Mysql/rename_user?oldname=$old_name&newname=$new_name");
236 236
     }
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
      *
241 241
      * @return bool|array|stdClass
242 242
      */
243
-    public static function dumpMysqlDatabaseSchema (string $database): bool|array|stdClass {
243
+    public static function dumpMysqlDatabaseSchema(string $database): bool | array | stdClass {
244 244
         if (!str_starts_with($database, self::$cpanelUser)) {
245
-            $database = self::$cpanelUser . '_' . $database;
245
+            $database = self::$cpanelUser.'_'.$database;
246 246
         }
247 247
         return self::execute("Mysql/dump_database_schema?dbname=$database");
248 248
     }
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
     /**
251 251
      * @return bool|array|stdClass
252 252
      */
253
-    public static function mysqlDatabases (): bool|array|stdClass {
253
+    public static function mysqlDatabases(): bool | array | stdClass {
254 254
         return self::execute('Mysql/list_databases');
255 255
     }
256 256
 
257 257
     /**
258 258
      * @return bool|array|stdClass
259 259
      */
260
-    public static function mysqlUsers (): bool|array|stdClass {
260
+    public static function mysqlUsers(): bool | array | stdClass {
261 261
         return self::execute('Mysql/list_users');
262 262
     }
263 263
 }
264 264
\ No newline at end of file
Please login to merge, or discard this patch.