Passed
Push — master ( 2cb055...b2403f )
by Ferry
04:01
created
src/controllers/AdminAuthController.php 1 patch
Braces   +7 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 
34 34
     public function getLogin()
35 35
     {
36
-        if(!auth()->guest()) return redirect(cb()->getAdminUrl());
36
+        if(!auth()->guest()) {
37
+            return redirect(cb()->getAdminUrl());
38
+        }
37 39
 
38 40
         cbHook()->hookGetLogin();
39 41
 
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
     public function postLogin()
44 46
     {
45 47
         try{
46
-            if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended"));
48
+            if($this->isSuspendedLogin()) {
49
+                throw new CBValidationException(cbLang("you_have_been_suspended"));
50
+            }
47 51
 
48 52
             cb()->validation([
49 53
                 'email'=>'required|email',
@@ -58,7 +62,7 @@  discard block
 block discarded – undo
58 62
                 $this->incrementFailedLogin();
59 63
                 return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']);
60 64
             }
61
-        }catch (CBValidationException $e) {
65
+        } catch (CBValidationException $e) {
62 66
             return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning');
63 67
         }
64 68
     }
Please login to merge, or discard this patch.
src/helpers/CurlHelper.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 
50 50
         if($err) {
51 51
             return $err;
52
-        }else {
52
+        } else {
53 53
             return $response;
54 54
         }
55 55
     }
Please login to merge, or discard this patch.
src/controllers/RegisterController.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
                 return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success");
70 70
             }
71 71
 
72
-        }catch (CBValidationException $e) {
72
+        } catch (CBValidationException $e) {
73 73
             return cb()->redirectBack($e->getMessage());
74 74
         }
75 75
 
Please login to merge, or discard this patch.
src/controllers/ForgetController.php 1 patch
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
                 return cb()->redirectBack("Your email is not registered");
59 59
             }
60 60
 
61
-        }catch (CBValidationException $e) {
61
+        } catch (CBValidationException $e) {
62 62
             return cb()->redirectBack($e->getMessage());
63 63
         } catch (\Exception $e) {
64 64
             Log::error($e);
Please login to merge, or discard this patch.
src/controllers/SubModuleController.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,12 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
     public function getSubModule($subModuleKey) {
17
-        if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
18
-        if(!verifyReferalUrl()) return cb()->redirect(module()->url(),"It looks like your url is incorrect");
17
+        if(!module()->canBrowse()) {
18
+            return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area"));
19
+        }
20
+        if(!verifyReferalUrl()) {
21
+            return cb()->redirect(module()->url(),"It looks like your url is incorrect");
22
+        }
19 23
 
20 24
         if($subModule = Cache::get("subModule".$subModuleKey)) {
21 25
             $foreignKey = $subModule['foreignKey'];
Please login to merge, or discard this patch.
src/helpers/MiscellanousSingleton.php 1 patch
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,8 +23,11 @@
 block discarded – undo
23 23
 
24 24
     public function hasData($key) {
25 25
         $data = $this->data;
26
-        if(isset($data[$key])) return true;
27
-        else return false;
26
+        if(isset($data[$key])) {
27
+            return true;
28
+        } else {
29
+            return false;
30
+        }
28 31
     }
29 32
 
30 33
     public function setData($key, $value): void
Please login to merge, or discard this patch.
src/helpers/CB.php 1 patch
Braces   +26 added lines, -12 removed lines patch added patch discarded remove patch
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
             if($resize_width || $resize_height) {
101 101
                 $this->resizeImage($file, $file_path.'/'.$filename, $resize_width, $resize_height);
102 102
                 return $file_path.'/'.$filename;
103
-            }else{
103
+            } else{
104 104
                 if (Storage::putFileAs($file_path, $file, $filename, 'public')) {
105 105
                     return $file_path.'/'.$filename;
106 106
                 } else {
107 107
                     throw new \Exception("Something went wrong, file can't upload!");
108 108
                 }
109 109
             }
110
-        }else{
110
+        } else{
111 111
             throw new \Exception("The file format is not allowed!");
112 112
         }
113 113
     }
@@ -129,10 +129,10 @@  discard block
 block discarded – undo
129 129
                 if($filename && $ext) {
130 130
                     return $this->uploadFileProcess($filename, $ext, $fileData, $encrypt, $resize_width, $resize_height);
131 131
                 }
132
-            }else {
132
+            } else {
133 133
                 throw new \Exception("Mime type not found");
134 134
             }
135
-        }else{
135
+        } else{
136 136
             throw new \Exception("Mime type not found");
137 137
         }
138 138
     }
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             }
210 210
 
211 211
             Storage::put($fullFilePath, $img, 'public');
212
-        }else{
212
+        } else{
213 213
             throw new \Exception("The file format is not allowed!");
214 214
         }
215 215
     }
@@ -233,7 +233,9 @@  discard block
 block discarded – undo
233 233
     {
234 234
         if (is_array($id)) {
235 235
             $idHash = md5("find".$table.serialize($id));
236
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
236
+            if(miscellanousSingleton()->hasData($idHash)) {
237
+                return miscellanousSingleton()->getData($idHash);
238
+            }
237 239
 
238 240
             $first = DB::table($table);
239 241
             foreach ($id as $k => $v) {
@@ -245,7 +247,9 @@  discard block
 block discarded – undo
245 247
             return $data;
246 248
         } else {
247 249
             $idHash = md5("find".$table.$id);
248
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
250
+            if(miscellanousSingleton()->hasData($idHash)) {
251
+                return miscellanousSingleton()->getData($idHash);
252
+            }
249 253
 
250 254
             $pk = $this->pk($table);
251 255
             $data = DB::table($table)->where($pk, $id)->first();
@@ -266,19 +270,25 @@  discard block
 block discarded – undo
266 270
 
267 271
         if(is_array($conditionOrCallback)) {
268 272
             $idHash = md5("findAll".$table.serialize($conditionOrCallback));
269
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
273
+            if(miscellanousSingleton()->hasData($idHash)) {
274
+                return miscellanousSingleton()->getData($idHash);
275
+            }
270 276
 
271 277
             $data = DB::table($table)->where($conditionOrCallback)->get();
272 278
         } elseif (is_callable($conditionOrCallback)) {
273 279
             $idHash = "findAll".$table.spl_object_hash($conditionOrCallback);
274
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
280
+            if(miscellanousSingleton()->hasData($idHash)) {
281
+                return miscellanousSingleton()->getData($idHash);
282
+            }
275 283
 
276 284
             $data = DB::table($table);
277 285
             $data = call_user_func($conditionOrCallback, $data);
278 286
             $data = $data->get();
279 287
         } else {
280 288
             $idHash = md5("findAll".$table.$conditionOrCallback);
281
-            if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
289
+            if(miscellanousSingleton()->hasData($idHash)) {
290
+                return miscellanousSingleton()->getData($idHash);
291
+            }
282 292
 
283 293
             $data = DB::table($table);
284 294
             if($conditionOrCallback) {
@@ -297,7 +307,9 @@  discard block
 block discarded – undo
297 307
     public function listAllTable()
298 308
     {
299 309
         $idHash = md5("listAllTable");
300
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
310
+        if(miscellanousSingleton()->hasData($idHash)) {
311
+            return miscellanousSingleton()->getData($idHash);
312
+        }
301 313
         $data = DB::connection()->getDoctrineSchemaManager()->listTableNames();
302 314
         miscellanousSingleton()->setData($idHash, $data);
303 315
         return $data;
@@ -306,7 +318,9 @@  discard block
 block discarded – undo
306 318
     public function listAllColumns($table)
307 319
     {
308 320
         $idHash = md5("listAllColumns".$table);
309
-        if(miscellanousSingleton()->hasData($idHash)) return miscellanousSingleton()->getData($idHash);
321
+        if(miscellanousSingleton()->hasData($idHash)) {
322
+            return miscellanousSingleton()->getData($idHash);
323
+        }
310 324
         $data = Schema::getColumnListing($table);
311 325
         miscellanousSingleton()->setData($idHash, $data);
312 326
         return $data;
Please login to merge, or discard this patch.
src/controllers/traits/Query.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                     if(SchemaHelper::hasColumn($this->data['table'], $column->getField())) {
48 48
                         $query->addSelect($this->data['table'].'.'.$column->getField());
49 49
                     }
50
-                }else{
50
+                } else{
51 51
                     $query->addSelect($column->getField());
52 52
                 }
53 53
             }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
             $keyword = sanitizeXSS(request("q"));
61 61
             if(isset($this->data['hook_search_query'])) {
62 62
                 $query = call_user_func($this->data['hook_search_query'], $query);
63
-            }else{
63
+            } else{
64 64
                 $query->where(function ($where) use ($columns, $keyword) {
65 65
                     /**
66 66
                      * @var $where Builder
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                     {
70 70
                         if(strpos($column->getField(),".") === false) {
71 71
                             $field = $this->data['table'].'.'.$column->getField();
72
-                        }else{
72
+                        } else{
73 73
                             $field = $column->getField();
74 74
                         }
75 75
                         $where->orWhere($field, 'like', '%'.$keyword.'%');
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                     $query->orderBy(request('order_by'), request('order_sort'));
112 112
                 }
113 113
             }
114
-        }else{
114
+        } else{
115 115
             /*
116 116
              * For default, query will be order by primary key as descending
117 117
              */
Please login to merge, or discard this patch.
src/helpers/Helper.php 1 patch
Braces   +25 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,8 +2,11 @@  discard block
 block discarded – undo
2 2
 if(!function_exists("isConfigCached")) {
3 3
     function isConfigCached()
4 4
     {
5
-        if(env("APP_NAME")=="" || env("APP_NAME")==null) return true;
6
-        else return false;
5
+        if(env("APP_NAME")=="" || env("APP_NAME")==null) {
6
+            return true;
7
+        } else {
8
+            return false;
9
+        }
7 10
     }
8 11
 }
9 12
 
@@ -113,7 +116,9 @@  discard block
 block discarded – undo
113 116
         }
114 117
 
115 118
         $str = substr($str, 0, -1);
116
-        if (!file_put_contents($envFile, $str)) return false;
119
+        if (!file_put_contents($envFile, $str)) {
120
+            return false;
121
+        }
117 122
         return true;
118 123
     }
119 124
 }
@@ -316,7 +321,7 @@  discard block
 block discarded – undo
316 321
             $settings = file_get_contents(storage_path('.cbconfig'));
317 322
             $settings = decrypt($settings);
318 323
             $settings = unserialize($settings);
319
-        }else{
324
+        } else{
320 325
             $settings = [];
321 326
         }
322 327
 
@@ -341,14 +346,14 @@  discard block
 block discarded – undo
341 346
             $settings = file_get_contents(storage_path('.cbconfig'));
342 347
             $settings = decrypt($settings);
343 348
             $settings = unserialize($settings);
344
-        }else{
349
+        } else{
345 350
             $settings = [];
346 351
         }
347 352
 
348 353
         if(isset($settings[$key])) {
349 354
             \Illuminate\Support\Facades\Cache::forever("setting_".$key, $settings[$key]);
350 355
             return $settings[$key]?:$default;
351
-        }else{
356
+        } else{
352 357
             return $default;
353 358
         }
354 359
     }
@@ -434,7 +439,7 @@  discard block
 block discarded – undo
434 439
         $url = request($name);
435 440
         if(filter_var($url, FILTER_VALIDATE_URL)) {
436 441
             return $url;
437
-        }else{
442
+        } else{
438 443
             return request()->url();
439 444
         }
440 445
     }
@@ -446,14 +451,14 @@  discard block
 block discarded – undo
446 451
             $response = request($name);
447 452
             if(is_string($response)) {
448 453
                 $response = sanitizeXSS($response);
449
-            }elseif (is_array($response)) {
454
+            } elseif (is_array($response)) {
450 455
                 array_walk_recursive($response, function(&$response) {
451 456
                     $response = sanitizeXSS($response);
452 457
                 });
453 458
             }
454 459
 
455 460
             return $response;
456
-        }else{
461
+        } else{
457 462
             return Request::get($name);
458 463
         }
459 464
     }
@@ -463,11 +468,13 @@  discard block
 block discarded – undo
463 468
     function min_var_export($input) {
464 469
         if(is_array($input)) {
465 470
             $buffer = [];
466
-            foreach($input as $key => $value)
467
-                $buffer[] = var_export($key, true)."=>".min_var_export($value);
471
+            foreach($input as $key => $value) {
472
+                            $buffer[] = var_export($key, true)."=>".min_var_export($value);
473
+            }
468 474
             return "[".implode(",",$buffer)."]";
469
-        } else
470
-            return var_export($input, true);
475
+        } else {
476
+                    return var_export($input, true);
477
+        }
471 478
     }
472 479
 }
473 480
 
@@ -480,10 +487,11 @@  discard block
 block discarded – undo
480 487
 	     $objects = scandir($dir); 
481 488
 	     foreach ($objects as $object) { 
482 489
 	       if ($object != "." && $object != "..") { 
483
-	         if (is_dir($dir."/".$object))
484
-	           rrmdir($dir."/".$object);
485
-	         else
486
-	           unlink($dir."/".$object); 
490
+	         if (is_dir($dir."/".$object)) {
491
+	         	           rrmdir($dir."/".$object);
492
+	         } else {
493
+	         	           unlink($dir."/".$object);
494
+	         }
487 495
 	       } 
488 496
 	     }
489 497
 	     rmdir($dir); 
Please login to merge, or discard this patch.