Completed
Push — 4.0 ( ad8a54...ed771a )
by Marco
06:33
created
src/Comodojo/Dispatcher/Response/Preprocessor/Status201.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 
31 31
         $location = $this->response()->location()->get();
32 32
 
33
-        if ( $location != null ) $this->response()->headers()->set("Location: ".$location);
33
+        if ($location != null) $this->response()->headers()->set("Location: ".$location);
34 34
 
35 35
         parent::consolidate();
36 36
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@
 block discarded – undo
30 30
 
31 31
         $location = $this->response()->location()->get();
32 32
 
33
-        if ( $location != null ) $this->response()->headers()->set("Location: ".$location);
33
+        if ( $location != null ) {
34
+            $this->response()->headers()->set("Location: ".$location);
35
+        }
34 36
 
35 37
         parent::consolidate();
36 38
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status301.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@
 block discarded – undo
32 32
 
33 33
         $location = $this->response()->location()->get();
34 34
 
35
-        if ( empty($location) ) throw new Exception("Invalid location, cannot redirect");
35
+        if (empty($location)) throw new Exception("Invalid location, cannot redirect");
36 36
 
37 37
         $this->response()->headers()->set("Location: ".$location);
38 38
 
39
-        if ( empty($this->response->content()->get()) ) {
39
+        if (empty($this->response->content()->get())) {
40 40
 
41 41
             $this->response->content()->set(sprintf('<!DOCTYPE html>
42 42
 <html>
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,9 @@
 block discarded – undo
32 32
 
33 33
         $location = $this->response()->location()->get();
34 34
 
35
-        if ( empty($location) ) throw new Exception("Invalid location, cannot redirect");
35
+        if ( empty($location) ) {
36
+            throw new Exception("Invalid location, cannot redirect");
37
+        }
36 38
 
37 39
         $this->response()->headers()->set("Location: ".$location);
38 40
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status405.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
         // An Allow Header should be provided from DispatcherException
34 34
         $allow = $this->response()->headers()->get('Allow');
35 35
 
36
-        if ( is_null($allow) ) throw new Exception("Missing Allow header");
36
+        if (is_null($allow)) throw new Exception("Missing Allow header");
37 37
 
38 38
         parent::consolidate();
39 39
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@
 block discarded – undo
33 33
         // An Allow Header should be provided from DispatcherException
34 34
         $allow = $this->response()->headers()->get('Allow');
35 35
 
36
-        if ( is_null($allow) ) throw new Exception("Missing Allow header");
36
+        if ( is_null($allow) ) {
37
+            throw new Exception("Missing Allow header");
38
+        }
37 39
 
38 40
         parent::consolidate();
39 41
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status200.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
         $type = $this->response()->content()->type();
34 34
         $charset = $this->response()->content()->charset();
35 35
 
36
-        if ( is_null($charset) ) {
36
+        if (is_null($charset)) {
37 37
             $this->response()->headers()->set("Content-type", strtolower($type));
38 38
         } else {
39 39
             $this->response()->headers()->set("Content-type", strtolower($type)."; charset=".$charset);
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Content.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
     }
40 40
 
41
-    public function set($content=null) {
41
+    public function set($content = null) {
42 42
 
43
-        if ( !is_scalar($content) && $content != null ) {
43
+        if (!is_scalar($content) && $content != null) {
44 44
 
45 45
             throw new Exception("Invalid HTTP content");
46 46
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
     public function type($type = null) {
56 56
 
57
-        if ( is_null($type) ) {
57
+        if (is_null($type)) {
58 58
 
59 59
             return $this->type;
60 60
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
     public function charset($charset = null) {
70 70
 
71
-        if ( is_null($charset) ) {
71
+        if (is_null($charset)) {
72 72
 
73 73
             return $this->charset;
74 74
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Model.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $output_class_name = "\\Comodojo\\Dispatcher\\Response\\Preprocessor\\Status".$status;
103 103
 
104 104
         // @TODO: this condition will be removed when all preprocessors ready
105
-        if ( class_exists($output_class_name) ) {
105
+        if (class_exists($output_class_name)) {
106 106
             $output = new $output_class_name($this);
107 107
         } else {
108 108
             $output = new \Comodojo\Dispatcher\Response\Preprocessor\Status200($this);
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 
111 111
         $output->consolidate();
112 112
 
113
-        if ( $route != null ) {
113
+        if ($route != null) {
114 114
             $this->setClientCache($request, $route);
115 115
         }
116 116
 
117 117
         // extra checks
118 118
 
119
-        if ( $request->method()->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) {
119
+        if ($request->method()->get() == 'HEAD' && !in_array($status, array(100, 101, 102, 204, 304))) {
120 120
             $length = $this->content()->length();
121 121
             $this->content()->set(null);
122 122
             if ($length) $this->headers()->set('Content-Length', $length);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
             $this->headers()->delete('Content-Length');
127 127
         }
128 128
 
129
-        if ( $request->version()->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
129
+        if ($request->version()->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
130 130
             $this->headers()->set('pragma', 'no-cache');
131 131
             $this->headers()->set('expires', -1);
132 132
         }
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
             //        the cache layer will be improoved in future versions.
147 147
         ) {
148 148
 
149
-            if ( $ttl > 0 ) {
149
+            if ($ttl > 0) {
150 150
 
151
-                $this->headers()->set("Cache-Control","max-age=".$ttl.", must-revalidate");
152
-                $this->headers()->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->getTimestamp() + $ttl)." GMT");
151
+                $this->headers()->set("Cache-Control", "max-age=".$ttl.", must-revalidate");
152
+                $this->headers()->set("Expires", gmdate("D, d M Y H:i:s", (int)$this->getTimestamp()+$ttl)." GMT");
153 153
 
154 154
             } else {
155 155
 
156
-                $this->headers()->set("Cache-Control","no-cache, must-revalidate");
157
-                $this->headers()->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
156
+                $this->headers()->set("Cache-Control", "no-cache, must-revalidate");
157
+                $this->headers()->set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
158 158
 
159 159
             }
160 160
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,9 @@
 block discarded – undo
119 119
         if ( $request->method()->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) {
120 120
             $length = $this->content()->length();
121 121
             $this->content()->set(null);
122
-            if ($length) $this->headers()->set('Content-Length', $length);
122
+            if ($length) {
123
+                $this->headers()->set('Content-Length', $length);
124
+            }
123 125
         }
124 126
 
125 127
         if ($this->headers()->get('Transfer-Encoding') != null) {
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Service/AbstractService.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 
97 97
         $supported_methods = $this->configuration()->get('supported-http-methods');
98 98
 
99
-        if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE');
99
+        if (is_null($supported_methods)) $supported_methods = array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PURGE');
100 100
 
101
-        if ( method_exists($this, 'any') ) {
101
+        if (method_exists($this, 'any')) {
102 102
 
103 103
             return $supported_methods;
104 104
 
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 
107 107
         $implemented_methods = array();
108 108
 
109
-        foreach ( $supported_methods as $method ) {
109
+        foreach ($supported_methods as $method) {
110 110
 
111
-            if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method);
111
+            if (method_exists($this, strtolower($method))) array_push($implemented_methods, $method);
112 112
 
113 113
         }
114 114
 
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function getMethod($method) {
124 124
 
125
-        if ( method_exists($this, strtolower($method)) ) {
125
+        if (method_exists($this, strtolower($method))) {
126 126
 
127 127
             return strtolower($method);
128 128
 
129
-        } else if ( method_exists($this, strtolower('any')) ) {
129
+        } else if (method_exists($this, strtolower('any'))) {
130 130
 
131 131
             return 'any';
132 132
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,7 +96,9 @@  discard block
 block discarded – undo
96 96
 
97 97
         $supported_methods = $this->configuration()->get('supported-http-methods');
98 98
 
99
-        if ( is_null($supported_methods) ) $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE');
99
+        if ( is_null($supported_methods) ) {
100
+            $supported_methods = array('GET','PUT','POST','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PURGE');
101
+        }
100 102
 
101 103
         if ( method_exists($this, 'any') ) {
102 104
 
@@ -108,7 +110,9 @@  discard block
 block discarded – undo
108 110
 
109 111
         foreach ( $supported_methods as $method ) {
110 112
 
111
-            if ( method_exists($this, strtolower($method)) ) array_push($implemented_methods,$method);
113
+            if ( method_exists($this, strtolower($method)) ) {
114
+                array_push($implemented_methods,$method);
115
+            }
112 116
 
113 117
         }
114 118
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Dispatcher.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $this->setTimestamp();
77 77
 
78 78
         // parsing configuration
79
-        $this->configuration = new Configuration( DefaultConfiguration::get() );
79
+        $this->configuration = new Configuration(DefaultConfiguration::get());
80 80
 
81 81
         $this->configuration()->merge($configuration);
82 82
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
         $this->logger()->debug("Emitting global dispatcher event.");
157 157
 
158
-        $this->events()->emit( new DispatcherEvent($this) );
158
+        $this->events()->emit(new DispatcherEvent($this));
159 159
 
160
-        if ( $this->configuration()->get('enabled') === false ) {
160
+        if ($this->configuration()->get('enabled') === false) {
161 161
 
162 162
             $this->logger()->debug("Dispatcher disabled, shutting down gracefully.");
163 163
 
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
 
174 174
         }
175 175
 
176
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request') );
176
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request'));
177 177
 
178
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request()->method()->get()) );
178
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request()->method()->get()));
179 179
 
180
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') );
180
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.request.#'));
181 181
 
182
-        if ( $this->readCache() ) {
182
+        if ($this->readCache()) {
183 183
 
184 184
             return $this->shutdown();
185 185
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
 
210 210
         $this->logger()->debug("Route acquired, type $route_type directed to $route_service.");
211 211
 
212
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route') );
212
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route'));
213 213
 
214
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type) );
214
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type));
215 215
 
216
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service) );
216
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service));
217 217
 
218
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') );
218
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.route.#'));
219 219
 
220 220
         // translate route to service
221 221
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 
244 244
     private function readCache() {
245 245
 
246
-        $name = (string) $this->request()->uri();
246
+        $name = (string)$this->request()->uri();
247 247
 
248 248
         $cache = $this->cache()->setNamespace('dispatcherservice')->get($name);
249 249
 
250
-        if ( is_null($cache) ) return false;
250
+        if (is_null($cache)) return false;
251 251
 
252 252
         $this->response = $cache;
253 253
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
         $cache = strtoupper($route->getParameter('cache'));
261 261
         $ttl = $route->getParameter('ttl');
262
-        $name = (string) $this->request()->uri();
262
+        $name = (string)$this->request()->uri();
263 263
         $method = $this->request()->method()->get();
264 264
         $status = $this->response()->status()->get();
265 265
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
         //        because of dispatcher internal structure: if post request is cached
268 268
         //        subsequent requests will never reach the service.
269 269
         if (
270
-            ( $cache == 'SERVER' || $cache == 'BOTH' ) &&
270
+            ($cache == 'SERVER' || $cache == 'BOTH') &&
271 271
             in_array($request->method()->get(), array('GET', 'HEAD')) &&
272 272
             in_array($this->status()->get(), array(200, 203, 300, 301, 302, 404, 410))
273
-        ){
273
+        ) {
274 274
 
275 275
             $this->cache()->setNamespace('dispatcherservice')->set($name, $this->response(), $ttl);
276 276
 
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 
283 283
         $params = $route->getParameter('headers');
284 284
 
285
-        if ( !empty($params) && is_array($params) ) {
285
+        if (!empty($params) && is_array($params)) {
286 286
 
287
-            foreach($params as $name=>$value) $this->response()->headers()->set($name, $value);
287
+            foreach ($params as $name=>$value) $this->response()->headers()->set($name, $value);
288 288
         }
289 289
 
290 290
     }
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 
325 325
         $this->response()->consolidate($this->request, $this->route);
326 326
 
327
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response') );
327
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response'));
328 328
 
329
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response()->status()->get()) );
329
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response()->status()->get()));
330 330
 
331
-        $this->events()->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') );
331
+        $this->events()->emit($this->emitServiceSpecializedEvents('dispatcher.response.#'));
332 332
 
333 333
         $this->logger()->debug("Composing return value.");
334 334
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
         $this->logger()->debug("Dispatcher run-cycle ends.");
338 338
 
339
-        if ( function_exists('fastcgi_finish_request') ) fastcgi_finish_request();
339
+        if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
340 340
         else ob_end_clean();
341 341
 
342 342
         return $return;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -247,7 +247,9 @@  discard block
 block discarded – undo
247 247
 
248 248
         $cache = $this->cache()->setNamespace('dispatcherservice')->get($name);
249 249
 
250
-        if ( is_null($cache) ) return false;
250
+        if ( is_null($cache) ) {
251
+            return false;
252
+        }
251 253
 
252 254
         $this->response = $cache;
253 255
 
@@ -284,7 +286,9 @@  discard block
 block discarded – undo
284 286
 
285 287
         if ( !empty($params) && is_array($params) ) {
286 288
 
287
-            foreach($params as $name=>$value) $this->response()->headers()->set($name, $value);
289
+            foreach($params as $name=>$value) {
290
+                $this->response()->headers()->set($name, $value);
291
+            }
288 292
         }
289 293
 
290 294
     }
@@ -336,8 +340,11 @@  discard block
 block discarded – undo
336 340
 
337 341
         $this->logger()->debug("Dispatcher run-cycle ends.");
338 342
 
339
-        if ( function_exists('fastcgi_finish_request') ) fastcgi_finish_request();
340
-        else ob_end_clean();
343
+        if ( function_exists('fastcgi_finish_request') ) {
344
+            fastcgi_finish_request();
345
+        } else {
346
+            ob_end_clean();
347
+        }
341 348
 
342 349
         return $return;
343 350
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Output/Processor.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
 
131 131
         $status = $this->response->status()->get();
132 132
 
133
-        if ( !array_key_exists($status, $this->codes) ) throw new Exception("Invalid HTTP status code in response");
133
+        if (!array_key_exists($status, $this->codes)) throw new Exception("Invalid HTTP status code in response");
134 134
 
135 135
         $message = $this->codes[$status];
136 136
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,9 @@
 block discarded – undo
130 130
 
131 131
         $status = $this->response->status()->get();
132 132
 
133
-        if ( !array_key_exists($status, $this->codes) ) throw new Exception("Invalid HTTP status code in response");
133
+        if ( !array_key_exists($status, $this->codes) ) {
134
+            throw new Exception("Invalid HTTP status code in response");
135
+        }
134 136
 
135 137
         $message = $this->codes[$status];
136 138
 
Please login to merge, or discard this patch.