Passed
Push — main ( 38b661...ecb236 )
by Alireza
04:36 queued 03:11
created
settings.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public static int $log_size = 10;
25 25
 
26
-    public static string|CURLFile|null $certificate = null;
26
+    public static string | CURLFile | null $certificate = null;
27 27
 
28 28
     public static bool $handler = true;
29 29
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 
54 54
     public static array $allowed_updates = ['message', 'edited_channel_post', 'callback_query', 'inline_query'];
55 55
 
56
-    public static array|mysqli|null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
56
+    public static array | mysqli | null $db = ['type' => 'json', 'file_name' => 'BPT-DB.json'];
57 57
 
58 58
 
59
-    public static function init (array|stdClass $settings) {
59
+    public static function init(array | stdClass $settings) {
60 60
         $settings = (array) $settings;
61 61
 
62 62
         if (!(isset($settings['logger']) && $settings['logger'] == false)) {
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
         }
65 65
 
66 66
         foreach ($settings as $setting => $value) {
67
-            try{
67
+            try {
68 68
                 self::$$setting = $value;
69 69
             }
70
-            catch (TypeError){
71
-                logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
70
+            catch (TypeError) {
71
+                logger::write("$setting setting has wrong type , its set to default value", loggerTypes::WARNING);
72 72
             }
73
-            catch (Error){
74
-                logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
73
+            catch (Error) {
74
+                logger::write("$setting setting is not one of library settings", loggerTypes::WARNING);
75 75
             }
76 76
         }
77 77
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
                 self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates();
84 84
             }
85 85
             else {
86
-                logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
86
+                logger::write('token format is not right, check it and try again', loggerTypes::ERROR);
87 87
                 throw new bptException('TOKEN_NOT_TRUE');
88 88
             }
89 89
         }
90 90
         else {
91
-            logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
91
+            logger::write('You must specify token parameter in settings', loggerTypes::ERROR);
92 92
             throw new bptException('TOKEN_NOT_FOUND');
93 93
         }
94 94
     }
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         if (self::$secure_folder) {
113 113
             $address = explode('/', $_SERVER['REQUEST_URI']);
114 114
             unset($address[count($address) - 1]);
115
-            $address = implode('/', $address) . '/BPT.php';
115
+            $address = implode('/', $address).'/BPT.php';
116 116
             $text = "ErrorDocument 404 $address\nErrorDocument 403 $address\n Options -Indexes\n  Order Deny,Allow\nDeny from all\nAllow from 127.0.0.1\n<Files *.php>\n    Order Allow,Deny\n    Allow from all\n</Files>";
117 117
             if (!file_exists('.htaccess') || filesize('.htaccess') != strlen($text)) {
118 118
                 file_put_contents('.htaccess', $text);
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
             getUpdates::init();
132 132
         }
133 133
         else {
134
-            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
134
+            logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler', loggerTypes::ERROR);
135 135
             throw new bptException('GETUPDATE_NEED_HANDLER');
136 136
         }
137 137
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -66,11 +66,9 @@  discard block
 block discarded – undo
66 66
         foreach ($settings as $setting => $value) {
67 67
             try{
68 68
                 self::$$setting = $value;
69
-            }
70
-            catch (TypeError){
69
+            } catch (TypeError){
71 70
                 logger::write("$setting setting has wrong type , its set to default value",loggerTypes::WARNING);
72
-            }
73
-            catch (Error){
71
+            } catch (Error){
74 72
                 logger::write("$setting setting is not one of library settings",loggerTypes::WARNING);
75 73
             }
76 74
         }
@@ -81,13 +79,11 @@  discard block
 block discarded – undo
81 79
                 self::secureFolder();
82 80
                 self::db();
83 81
                 self::$receiver !== receiver::GETUPDATES ? self::webhook() : self::getUpdates();
84
-            }
85
-            else {
82
+            } else {
86 83
                 logger::write('token format is not right, check it and try again',loggerTypes::ERROR);
87 84
                 throw new bptException('TOKEN_NOT_TRUE');
88 85
             }
89
-        }
90
-        else {
86
+        } else {
91 87
             logger::write('You must specify token parameter in settings',loggerTypes::ERROR);
92 88
             throw new bptException('TOKEN_NOT_FOUND');
93 89
         }
@@ -129,8 +125,7 @@  discard block
 block discarded – undo
129 125
     private static function getUpdates() {
130 126
         if (self::$handler) {
131 127
             getUpdates::init();
132
-        }
133
-        else {
128
+        } else {
134 129
             logger::write('You can\'t use getUpdates receiver when handler is off , use webhook or use handler',loggerTypes::ERROR);
135 130
             throw new bptException('GETUPDATE_NEED_HANDLER');
136 131
         }
Please login to merge, or discard this patch.
database/database.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
17 17
    /**
18 18
    * @const types database
19 19
    */
20
-   const TYPES = array('Mysqli','Medoo','Json');
20
+   const TYPES = array('Mysqli', 'Medoo', 'Json');
21 21
  
22 22
    /**
23 23
     * @const Medoo database types
24 24
     */
25
-   const Medoo_Types = array('mysql','mariadb','pgsql','sybase','oracle','mssql', 'sqlite');
25
+   const Medoo_Types = array('mysql', 'mariadb', 'pgsql', 'sybase', 'oracle', 'mssql', 'sqlite');
26 26
 
27 27
     /**
28 28
      * @var type database
Please login to merge, or discard this patch.
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
   
3
- //define namespace
4
- namespace BPT;
3
+    //define namespace
4
+    namespace BPT;
5 5
  
6
- //use classes
7
- use Medoo\Medoo;
8
- use BPT\jsondb
6
+    //use classes
7
+    use Medoo\Medoo;
8
+    use BPT\jsondb
9 9
  
10 10
  
11
-  /**
12
-   * @class Database
13
-   */
14
-  class database
15
-  {
11
+    /**
12
+     * @class Database
13
+     */
14
+    class database
15
+    {
16 16
         
17
-   /**
18
-   * @const types database
19
-   */
20
-   const TYPES = array('Mysqli','Medoo','Json');
17
+    /**
18
+     * @const types database
19
+     */
20
+    const TYPES = array('Mysqli','Medoo','Json');
21 21
  
22
-   /**
23
-    * @const Medoo database types
24
-    */
25
-   const Medoo_Types = array('mysql','mariadb','pgsql','sybase','oracle','mssql', 'sqlite');
22
+    /**
23
+     * @const Medoo database types
24
+     */
25
+    const Medoo_Types = array('mysql','mariadb','pgsql','sybase','oracle','mssql', 'sqlite');
26 26
 
27 27
     /**
28 28
      * @var type database
@@ -36,40 +36,40 @@  discard block
 block discarded – undo
36 36
     protected $host;
37 37
        
38 38
     /**
39
-      * @var username database username 
40
-      */
39
+     * @var username database username 
40
+     */
41 41
     protected $username;
42 42
       
43 43
     /**
44
-      * @var dbname database name
45
-      */
44
+     * @var dbname database name
45
+     */
46 46
     protected $dbname;
47 47
        
48 48
     /**
49
-      * @var charset database
50
-      */
49
+     * @var charset database
50
+     */
51 51
     protected $charset;
52 52
         
53 53
     /**
54
-      * @var password database password
55
-      */
54
+     * @var password database password
55
+     */
56 56
     protected $password;
57 57
        
58 58
     /**
59
-      * @var connection database
60
-      */
59
+     * @var connection database
60
+     */
61 61
     protected $connect;
62 62
        
63
-      /**
64
-       * @method Json_init
65
-       * Create a Json database
66
-       */
67
-      protected function Json_init()
68
-      {
63
+        /**
64
+         * @method Json_init
65
+         * Create a Json database
66
+         */
67
+        protected function Json_init()
68
+        {
69 69
         $JsonDb = new JsonDb();
70 70
         $JsonDb->init($this->dbname);
71
-      }
71
+        }
72 72
       
73 73
       
74 74
       
75
-  }
75
+    }
Please login to merge, or discard this patch.
database/handller.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
        */
18 18
       public function __construct(array $settings)
19 19
       {
20
-        if(in_array($settings['type'],self::TYPES)){
21
-              if($settings['type'] === 'Mysqli'){
22
-                  if(self::CheckParam($settings)){
20
+        if (in_array($settings['type'], self::TYPES)) {
21
+              if ($settings['type'] === 'Mysqli') {
22
+                  if (self::CheckParam($settings)) {
23 23
                  $db = new Mysqlidb([
24 24
                 'host' => $this->host,
25 25
                 'username' => $this->username,
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
                 'db' => $this->dbname,
28 28
                 'charset' => $this->charset
29 29
                 ]);
30
-                if($db){
30
+                if ($db) {
31 31
                   $this->connect = $db;
32 32
                } else {
33 33
                   throw new \exception('a problem to connecting');
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
                   throw new \exception('required parameters not found');
37 37
                }
38 38
              }
39
-              if($settings['type'] === 'Json' and isset($settings['dbname'])){
39
+              if ($settings['type'] === 'Json' and isset($settings['dbname'])) {
40 40
                 $this->type = $settings['type'];
41 41
                 $this->dbname = $settings['dbname'];
42 42
                 parent::Json_init();
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
           }
49 49
       }
50 50
       
51
-      private static function CheckParam(array $array){
52
-         if(isset($array['username']) && isset($array['dbname']) && isset($array['password'])){
51
+      private static function CheckParam(array $array) {
52
+         if (isset($array['username']) && isset($array['dbname']) && isset($array['password'])) {
53 53
             $this->host = $array['host'] ?? 'localhost';
54 54
             $this->username = $array['username'];
55 55
             $this->dbname = $array['dbname'];
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-  //define namespace
4
-  namespace BPT\Database;
3
+    //define namespace
4
+    namespace BPT\Database;
5 5
   
6
-  //use class
7
-  use BPT\database;
6
+    //use class
7
+    use BPT\database;
8 8
   
9
-  /**
10
-   * 
11
-   */
12
-  class handller extends database
13
-  {
9
+    /**
10
+     * 
11
+     */
12
+    class handller extends database
13
+    {
14 14
       
15
-      /**
16
-       * 
17
-       */
18
-      public function __construct(array $settings)
19
-      {
15
+        /**
16
+         * 
17
+         */
18
+        public function __construct(array $settings)
19
+        {
20 20
         if(in_array($settings['type'],self::TYPES)){
21
-              if($settings['type'] === 'Mysqli'){
22
-                  if(self::CheckParam($settings)){
23
-                 $db = new Mysqlidb([
21
+                if($settings['type'] === 'Mysqli'){
22
+                    if(self::CheckParam($settings)){
23
+                    $db = new Mysqlidb([
24 24
                 'host' => $this->host,
25 25
                 'username' => $this->username,
26 26
                 'password' => $this->password,
@@ -28,36 +28,36 @@  discard block
 block discarded – undo
28 28
                 'charset' => $this->charset
29 29
                 ]);
30 30
                 if($db){
31
-                  $this->connect = $db;
32
-               } else {
33
-                  throw new \exception('a problem to connecting');
34
-                 }
35
-               } else {
36
-                  throw new \exception('required parameters not found');
37
-               }
38
-             }
39
-              if($settings['type'] === 'Json' and isset($settings['dbname'])){
31
+                    $this->connect = $db;
32
+                } else {
33
+                    throw new \exception('a problem to connecting');
34
+                    }
35
+                } else {
36
+                    throw new \exception('required parameters not found');
37
+                }
38
+                }
39
+                if($settings['type'] === 'Json' and isset($settings['dbname'])){
40 40
                 $this->type = $settings['type'];
41 41
                 $this->dbname = $settings['dbname'];
42 42
                 parent::Json_init();
43
-              } else {
43
+                } else {
44 44
                 throw new \exception('parameter dbanme not found');
45
-             }
46
-          } else {
47
-              throw new \exception('parameter type not found');
48
-          }
49
-      }
45
+                }
46
+            } else {
47
+                throw new \exception('parameter type not found');
48
+            }
49
+        }
50 50
       
51
-      private static function CheckParam(array $array){
52
-         if(isset($array['username']) && isset($array['dbname']) && isset($array['password'])){
51
+        private static function CheckParam(array $array){
52
+            if(isset($array['username']) && isset($array['dbname']) && isset($array['password'])){
53 53
             $this->host = $array['host'] ?? 'localhost';
54 54
             $this->username = $array['username'];
55 55
             $this->dbname = $array['dbname'];
56 56
             $this->password = $array['password'];
57 57
             $this->charset = $array['charset'] ?? 'utf8mb4';
58
-             return true;
59
-         } else {
60
-             return false;
61
-         }
62
-      }
63
-  }
64 58
\ No newline at end of file
59
+                return true;
60
+            } else {
61
+                return false;
62
+            }
63
+        }
64
+    }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.