Passed
Push — main ( b5303f...532590 )
by Sammy
01:25
created
Controllers/Interfaces/DisplayControllerInterface.class.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 interface DisplayControllerInterface extends BaseController
6 6
 {
7 7
 
8
-   /*
8
+    /*
9 9
       The viewport is an associative array of values to be exported as variables in the view
10 10
          the assoc keys will be the variable names
11 11
 
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
            returns null
43 43
    */
44 44
 
45
-   public function viewport($key=null, $value=null, $coercion=false);
45
+    public function viewport($key=null, $value=null, $coercion=false);
46 46
 
47
-   public function display($custom_template = null, $standalone=false);
47
+    public function display($custom_template = null, $standalone=false);
48 48
 
49 49
 }
Please login to merge, or discard this patch.
Router/hopper.class.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 
11 11
 class hopper extends \AltoRouter implements RouterInterface
12 12
 {
13
-  private $match=null;
14
-  private $file_root=null;
13
+  private $match = null;
14
+  private $file_root = null;
15 15
   private $controller_namespaces = null;
16 16
 
17 17
   //----------------------------------------------------------- INITIALISATION
18 18
   public function __construct($settings)
19 19
   {
20
-    if(!isset($settings['route_home']))
20
+    if (!isset($settings['route_home']))
21 21
       throw new RouterException('ROUTE_HOME_UNDEFINED');
22 22
 
23 23
     parent::__construct();
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
   {
45 45
     $this->match = parent::match($requestUrl, $requestMethod);
46 46
 
47
-    if($this->match === false)
47
+    if ($this->match === false)
48 48
       throw new RouterException('ROUTE_MATCH_FALSE');
49 49
 
50 50
     $res = explode('::', self::target());
51 51
 
52
-    if($res === false || !isset($res[1]) || isset($ret[2]))
52
+    if ($res === false || !isset($res[1]) || isset($ret[2]))
53 53
       throw new RouterException('INVALID_TARGET');
54 54
 
55 55
     // if($this->match['name'] === 'akadok_controller_method')
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
     $target_method = $res[1];
61 61
     $found = false;
62 62
 
63
-    foreach($this->controller_namespaces as $controller_ns)
64
-      if($found = class_exists($controller_class_name = "$controller_ns$target_controller"))
63
+    foreach ($this->controller_namespaces as $controller_ns)
64
+      if ($found = class_exists($controller_class_name = "$controller_ns$target_controller"))
65 65
         break;
66 66
 
67
-    if($found === false)
67
+    if ($found === false)
68 68
       throw new RouterException('INVALID_CONTROLLER_NAME');
69 69
 
70 70
     $this->match['target_controller'] = $controller_class_name;
@@ -73,29 +73,29 @@  discard block
 block discarded – undo
73 73
     return [$controller_class_name, $target_method];
74 74
   }
75 75
 
76
-  public function params($param_name=null)
76
+  public function params($param_name = null)
77 77
   {
78 78
     return $this->extract_request($this->match['params'] ?? [], $param_name);
79 79
   }
80 80
 
81
-  public function submitted($param_name=null)
81
+  public function submitted($param_name = null)
82 82
   {
83 83
     return $this->extract_request($_POST, $param_name);
84 84
   }
85 85
 
86
-  private function extract_request($dat_ass, $key=null)
86
+  private function extract_request($dat_ass, $key = null)
87 87
   {
88 88
 
89 89
     // $key is null, returns $dat_ass or empty array
90
-    if(is_null($key))
90
+    if (is_null($key))
91 91
       return $dat_ass ?? [];
92 92
 
93 93
     // $dat_ass[$key] not set, returns null
94
-    if(!isset($dat_ass[$key]))
94
+    if (!isset($dat_ass[$key]))
95 95
       return null;
96 96
 
97 97
     // $dat_ass[$key] is a string, returns decoded value
98
-    if(is_string($dat_ass[$key]))
98
+    if (is_string($dat_ass[$key]))
99 99
       return urldecode($dat_ass[$key]);
100 100
 
101 101
     // $dat_ass[$key] is not a string, return match[$key]
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
    *  - an assoc_array of url params (strongly AltoRouter-based)
143 143
    * returns: something to put in a href="", action="" or header('Location:');
144 144
    */
145
-  public function prehop($route, $route_params=[])
145
+  public function prehop($route, $route_params = [])
146 146
   {
147
-    try{
147
+    try {
148 148
       $url = $this->generate($route, $route_params);
149
-    }catch(\Exception $e){
149
+    } catch (\Exception $e) {
150 150
       $url = $this->prehop(self::ROUTE_HOME_NAME);
151 151
     }
152 152
 
153 153
     return $url;
154 154
   }
155 155
 
156
-  public function prehop_here($url=null)
156
+  public function prehop_here($url = null)
157 157
   {
158 158
     return $url ?? $_SERVER['REQUEST_URI'];
159 159
   }
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
    *    - a url, go there
166 166
    * @params $route_params, assoc_data for url creation (i:id, a:format, ..)
167 167
    */
168
-  public function hop($route=null, $route_params=[])
168
+  public function hop($route = null, $route_params = [])
169 169
   {
170 170
     $url = null;
171 171
 
172
-    if(is_null($route))
172
+    if (is_null($route))
173 173
       $url = $this->prehop(self::ROUTE_HOME_NAME, $route_params);
174
-    elseif(is_string($route) && $this->route_exists($route))
174
+    elseif (is_string($route) && $this->route_exists($route))
175 175
       $url = $this->prehop($route, $route_params);
176 176
     else
177 177
       $url = $route;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
   // hops back to previous page (referer()), or home if no referer
183 183
   public function hop_back()
184 184
   {
185
-    if(!is_null($back = $this->referer()))
185
+    if (!is_null($back = $this->referer()))
186 186
       $this->hop_url($back);
187 187
 
188 188
     $this->hop();
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
   // returns null if same as current URL (prevents endless redirection loop)
201 201
   public function referer()
202 202
   {
203
-    if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host() .$_SERVER['REQUEST_URI'])
203
+    if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host().$_SERVER['REQUEST_URI'])
204 204
       return $_SERVER['HTTP_REFERER'];
205 205
 
206 206
     return null;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
   public function send_file($file_path)
210 210
   {
211
-    if(!file_exists($file_path))
211
+    if (!file_exists($file_path))
212 212
       throw new RouterException('SENDING_NON_EXISTING_FILE');
213 213
 
214 214
     $file_name = basename($file_path);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     //Get file type and set it as Content Type
217 217
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
218 218
 
219
-    header('Content-Type: ' . finfo_file($finfo, $file_path));
219
+    header('Content-Type: '.finfo_file($finfo, $file_path));
220 220
 
221 221
     finfo_close($finfo);
222 222
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     header('Pragma: public');
230 230
 
231 231
     //Define file size
232
-    header('Content-Length: ' . filesize($file_path));
232
+    header('Content-Length: '.filesize($file_path));
233 233
 
234 234
     ob_clean();
235 235
     flush();
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 
256 256
   public function web_root() : string
257 257
   {
258
-    return $this->web_host() . $this->web_base();
258
+    return $this->web_host().$this->web_base();
259 259
   }
260 260
 
261 261
   public function web_base() : string
Please login to merge, or discard this patch.
Braces   +41 added lines, -29 removed lines patch added patch discarded remove patch
@@ -17,8 +17,9 @@  discard block
 block discarded – undo
17 17
   //----------------------------------------------------------- INITIALISATION
18 18
   public function __construct($settings)
19 19
   {
20
-    if(!isset($settings['route_home']))
21
-      throw new RouterException('ROUTE_HOME_UNDEFINED');
20
+    if(!isset($settings['route_home'])) {
21
+          throw new RouterException('ROUTE_HOME_UNDEFINED');
22
+    }
22 23
 
23 24
     parent::__construct();
24 25
 
@@ -44,13 +45,15 @@  discard block
 block discarded – undo
44 45
   {
45 46
     $this->match = parent::match($requestUrl, $requestMethod);
46 47
 
47
-    if($this->match === false)
48
-      throw new RouterException('ROUTE_MATCH_FALSE');
48
+    if($this->match === false) {
49
+          throw new RouterException('ROUTE_MATCH_FALSE');
50
+    }
49 51
 
50 52
     $res = explode('::', self::target());
51 53
 
52
-    if($res === false || !isset($res[1]) || isset($ret[2]))
53
-      throw new RouterException('INVALID_TARGET');
54
+    if($res === false || !isset($res[1]) || isset($ret[2])) {
55
+          throw new RouterException('INVALID_TARGET');
56
+    }
54 57
 
55 58
     // if($this->match['name'] === 'akadok_controller_method')
56 59
     //   $res = [ucfirst(self::params('controller')).'Controller', ucfirst(self::params('method'))];
@@ -60,12 +63,14 @@  discard block
 block discarded – undo
60 63
     $target_method = $res[1];
61 64
     $found = false;
62 65
 
63
-    foreach($this->controller_namespaces as $controller_ns)
64
-      if($found = class_exists($controller_class_name = "$controller_ns$target_controller"))
66
+    foreach($this->controller_namespaces as $controller_ns) {
67
+          if($found = class_exists($controller_class_name = "$controller_ns$target_controller"))
65 68
         break;
69
+    }
66 70
 
67
-    if($found === false)
68
-      throw new RouterException('INVALID_CONTROLLER_NAME');
71
+    if($found === false) {
72
+          throw new RouterException('INVALID_CONTROLLER_NAME');
73
+    }
69 74
 
70 75
     $this->match['target_controller'] = $controller_class_name;
71 76
     $this->match['target_method'] = $target_method;
@@ -87,16 +92,19 @@  discard block
 block discarded – undo
87 92
   {
88 93
 
89 94
     // $key is null, returns $dat_ass or empty array
90
-    if(is_null($key))
91
-      return $dat_ass ?? [];
95
+    if(is_null($key)) {
96
+          return $dat_ass ?? [];
97
+    }
92 98
 
93 99
     // $dat_ass[$key] not set, returns null
94
-    if(!isset($dat_ass[$key]))
95
-      return null;
100
+    if(!isset($dat_ass[$key])) {
101
+          return null;
102
+    }
96 103
 
97 104
     // $dat_ass[$key] is a string, returns decoded value
98
-    if(is_string($dat_ass[$key]))
99
-      return urldecode($dat_ass[$key]);
105
+    if(is_string($dat_ass[$key])) {
106
+          return urldecode($dat_ass[$key]);
107
+    }
100 108
 
101 109
     // $dat_ass[$key] is not a string, return match[$key]
102 110
     return $dat_ass[$key];
@@ -146,7 +154,7 @@  discard block
 block discarded – undo
146 154
   {
147 155
     try{
148 156
       $url = $this->generate($route, $route_params);
149
-    }catch(\Exception $e){
157
+    } catch(\Exception $e){
150 158
       $url = $this->prehop(self::ROUTE_HOME_NAME);
151 159
     }
152 160
 
@@ -169,12 +177,13 @@  discard block
 block discarded – undo
169 177
   {
170 178
     $url = null;
171 179
 
172
-    if(is_null($route))
173
-      $url = $this->prehop(self::ROUTE_HOME_NAME, $route_params);
174
-    elseif(is_string($route) && $this->route_exists($route))
175
-      $url = $this->prehop($route, $route_params);
176
-    else
177
-      $url = $route;
180
+    if(is_null($route)) {
181
+          $url = $this->prehop(self::ROUTE_HOME_NAME, $route_params);
182
+    } elseif(is_string($route) && $this->route_exists($route)) {
183
+          $url = $this->prehop($route, $route_params);
184
+    } else {
185
+          $url = $route;
186
+    }
178 187
 
179 188
     $this->hop_url($url);
180 189
   }
@@ -182,8 +191,9 @@  discard block
 block discarded – undo
182 191
   // hops back to previous page (referer()), or home if no referer
183 192
   public function hop_back()
184 193
   {
185
-    if(!is_null($back = $this->referer()))
186
-      $this->hop_url($back);
194
+    if(!is_null($back = $this->referer())) {
195
+          $this->hop_url($back);
196
+    }
187 197
 
188 198
     $this->hop();
189 199
   }
@@ -200,16 +210,18 @@  discard block
 block discarded – undo
200 210
   // returns null if same as current URL (prevents endless redirection loop)
201 211
   public function referer()
202 212
   {
203
-    if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host() .$_SERVER['REQUEST_URI'])
204
-      return $_SERVER['HTTP_REFERER'];
213
+    if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host() .$_SERVER['REQUEST_URI']) {
214
+          return $_SERVER['HTTP_REFERER'];
215
+    }
205 216
 
206 217
     return null;
207 218
   }
208 219
 
209 220
   public function send_file($file_path)
210 221
   {
211
-    if(!file_exists($file_path))
212
-      throw new RouterException('SENDING_NON_EXISTING_FILE');
222
+    if(!file_exists($file_path)) {
223
+          throw new RouterException('SENDING_NON_EXISTING_FILE');
224
+    }
213 225
 
214 226
     $file_name = basename($file_path);
215 227
 
Please login to merge, or discard this patch.