Passed
Branch master (f8decb)
by Stone
02:25
created
App/Controllers/Debug.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace App\Controllers;
3 3
 
4
-class Debug{
5
-    public function index($test = ''){
4
+class Debug {
5
+    public function index($test = '') {
6 6
         echo 'Ok '.$test.'<br>';
7 7
         echo 'the router is working \\o/';
8 8
     }
9
-    public function test($test = '', $test2 = ''){
9
+    public function test($test = '', $test2 = '') {
10 10
         echo 'Ok '.$test.' - '.$test2.'<br>';
11 11
         echo 'the router is working \\o/';
12 12
     }
Please login to merge, or discard this patch.
App/Controllers/Admin/Debug.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace App\Controllers\Admin;
3 3
 
4
-class Debug{
5
-    public function index($test = ''){
4
+class Debug {
5
+    public function index($test = '') {
6 6
         echo 'Ok '.$test.'<br>';
7 7
         echo 'the router is working \\o/';
8 8
     }
9
-    public function test($test = '', $test2 = ''){
9
+    public function test($test = '', $test2 = '') {
10 10
         echo 'Ok '.$test.' - '.$test2.'<br>';
11 11
         echo 'the router is working \\o/';
12 12
     }
13
-    public function addTest($test = ''){
13
+    public function addTest($test = '') {
14 14
         echo 'Ok '.$test.'<br>';
15 15
         echo 'the router is working \\o/';
16 16
     }
Please login to merge, or discard this patch.
Core/Router.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             return $url;
111 111
         }
112 112
         return [];
113
-   }
113
+    }
114 114
 
115 115
 
116 116
     /**
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         }else{
140 140
             throw new \Exception("Class <i>$controllerWithNamespace</i> doesn't exist", 404);
141 141
         }
142
-   }
142
+    }
143 143
 
144 144
     /**
145 145
      * Convert the string with hyphens to StudlyCaps,
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * PHP version 7
11 11
  */
12
-class Router{
12
+class Router {
13 13
 
14 14
     /**
15 15
      * the default namespace
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
      * will then call the dispatcher to instantiate the controller and method
53 53
      *
54 54
      */
55
-    public function __construct(){
55
+    public function __construct() {
56 56
         //get the current url
57 57
         $url = $this->getUrl();
58 58
 
59 59
         //checking if a special namespace is present at the start of the url.
60 60
         //if so, then strip and set the new namespace
61
-        if(isset($url[0]) && in_array($url[0],$this->sections) ){
61
+        if (isset($url[0]) && in_array($url[0], $this->sections)) {
62 62
             $specialNamespace = array_shift($url);
63 63
 
64 64
             //making sure we have a single backslash
65
-            $specialNamespace = rtrim($specialNamespace,'\\').'\\';
65
+            $specialNamespace = rtrim($specialNamespace, '\\').'\\';
66 66
 
67 67
             //capitalize the special namespace
68 68
             $specialNamespace = $this->convertToStudlyCaps($specialNamespace);
@@ -71,18 +71,18 @@  discard block
 block discarded – undo
71 71
         }
72 72
 
73 73
         //applying the controllers and methods
74
-        if (isset($url[0]) && $url[0] != null){
74
+        if (isset($url[0]) && $url[0] != null) {
75 75
             $this->currentController = $this->convertToStudlyCaps($url[0]);
76 76
             unset($url[0]);
77 77
         }
78 78
 
79
-        if(isset($url[1]) && $url[1] != null){
79
+        if (isset($url[1]) && $url[1] != null) {
80 80
             $this->currentMethod = $this->convertToCamelCase($url[1]);
81 81
             unset($url[1]);
82 82
         }
83 83
 
84 84
         //grabbing the remaining parameters
85
-        $this->currentParams = $url? array_values($url) : [];
85
+        $this->currentParams = $url ? array_values($url) : [];
86 86
         $this->dispatch();
87 87
     }
88 88
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      * @return array decomposed url
94 94
      */
95 95
     protected function getUrl(): array{
96
-        if(isset($_GET['url'])){
96
+        if (isset($_GET['url'])) {
97 97
             //remove right slash
98 98
             $url = rtrim($_GET['url'], '/');
99 99
 
@@ -125,18 +125,18 @@  discard block
 block discarded – undo
125 125
 
126 126
         //try to create the controller object
127 127
         $controllerWithNamespace = $this->currentNamespace.$this->currentController;
128
-        if(class_exists($controllerWithNamespace)){
128
+        if (class_exists($controllerWithNamespace)) {
129 129
             $controllerInstantiated = new $controllerWithNamespace();
130 130
 
131 131
             //try to run the associated method and the pass parameters
132 132
             $methodToRun = $this->currentMethod;
133
-            if(method_exists($controllerInstantiated, $methodToRun)){
133
+            if (method_exists($controllerInstantiated, $methodToRun)) {
134 134
                 call_user_func_array([$controllerInstantiated, $methodToRun], $this->currentParams);
135
-            }else{
135
+            }else {
136 136
                 throw new \Exception("ERROR - Method <i>$methodToRun</i>() doesn't exist or is inaccessible");
137 137
             }
138 138
 
139
-        }else{
139
+        }else {
140 140
             throw new \Exception("Class <i>$controllerWithNamespace</i> doesn't exist", 404);
141 141
         }
142 142
    }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -132,11 +132,11 @@
 block discarded – undo
132 132
             $methodToRun = $this->currentMethod;
133 133
             if(method_exists($controllerInstantiated, $methodToRun)){
134 134
                 call_user_func_array([$controllerInstantiated, $methodToRun], $this->currentParams);
135
-            }else{
135
+            } else{
136 136
                 throw new \Exception("ERROR - Method <i>$methodToRun</i>() doesn't exist or is inaccessible");
137 137
             }
138 138
 
139
-        }else{
139
+        } else{
140 140
             throw new \Exception("Class <i>$controllerWithNamespace</i> doesn't exist", 404);
141 141
         }
142 142
    }
Please login to merge, or discard this patch.
Core/Error.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 /*
6 6
  * error and exception handler
7 7
  */
8
-class Error{
8
+class Error {
9 9
     /*
10 10
      * Error handler. Convert all errors to exceptions by throwing an errorException
11 11
      *
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      *
21 21
      */
22 22
     public static function errorhandler($level, $message, $file, $line):void{
23
-        if(error_reporting() !== 0){
23
+        if (error_reporting() !== 0) {
24 24
             //to keep the @ operator working
25 25
             throw new \ErrorException($message, 0, $level, $file, $line);
26 26
         }
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public static function exceptionHandler($exception):void{
37 37
         //code is 404 (not found) or 500 (general error)
38 38
         $code = $exception->getCode();
39
-        if ($code != 404){
39
+        if ($code != 404) {
40 40
             $code = 500;
41 41
         }//TODO Use code here to create 404.twig and 500.twig
42 42
 
Please login to merge, or discard this patch.