Completed
Push — 4.0 ( a1234e...3b08f9 )
by Marco
03:21
created
src/Comodojo/Dispatcher/Components/DataSerialization.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
      *
42 42
      * @param string $data Serialized data
43 43
      *
44
-     * @return Routes $this
44
+     * @return boolean $this
45 45
      */
46 46
     public function unserialize($data) {
47 47
 
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
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
         $output_class_name = "\\Comodojo\\Dispatcher\\Response\\Preprocessor\\Status".$status;
63 63
 
64 64
         // @TODO: this condition will be removed when all preprocessors ready
65
-        if ( class_exists($output_class_name) ) {
65
+        if (class_exists($output_class_name)) {
66 66
             $output = new $output_class_name($this);
67 67
         } else {
68 68
             $output = new \Comodojo\Dispatcher\Response\Preprocessor\Status200($this);
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 
71 71
         $output->consolidate();
72 72
 
73
-        if ( $route != null ) {
73
+        if ($route != null) {
74 74
             $this->setClientCache($request, $route);
75 75
         }
76 76
 
77 77
         // extra checks
78 78
 
79
-        if ( $request->method->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) {
79
+        if ($request->method->get() == 'HEAD' && !in_array($status, array(100, 101, 102, 204, 304))) {
80 80
             $length = $this->content->length();
81 81
             $this->content->set(null);
82 82
             if ($length) $this->headers->set('Content-Length', $length);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
             $this->headers->delete('Content-Length');
87 87
         }
88 88
 
89
-        if ( $request->version->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
89
+        if ($request->version->get() == '1.0' && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) {
90 90
             $this->headers->set('pragma', 'no-cache');
91 91
             $this->headers->set('expires', -1);
92 92
         }
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
             //        the cache layer will be improoved in future versions.
107 107
         ) {
108 108
 
109
-            if ( $ttl > 0 ) {
109
+            if ($ttl > 0) {
110 110
 
111
-                $this->headers->set("Cache-Control","max-age=".$ttl.", must-revalidate");
112
-                $this->headers->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->getTimestamp() + $ttl)." GMT");
111
+                $this->headers->set("Cache-Control", "max-age=".$ttl.", must-revalidate");
112
+                $this->headers->set("Expires", gmdate("D, d M Y H:i:s", (int)$this->getTimestamp()+$ttl)." GMT");
113 113
 
114 114
             } else {
115 115
 
116
-                $this->headers->set("Cache-Control","no-cache, must-revalidate");
117
-                $this->headers->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
116
+                $this->headers->set("Cache-Control", "no-cache, must-revalidate");
117
+                $this->headers->set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
118 118
 
119 119
             }
120 120
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@
 block discarded – undo
79 79
         if ( $request->method->get() == 'HEAD' && !in_array($status, array(100,101,102,204,304)) ) {
80 80
             $length = $this->content->length();
81 81
             $this->content->set(null);
82
-            if ($length) $this->headers->set('Content-Length', $length);
82
+            if ($length) {
83
+                $this->headers->set('Content-Length', $length);
84
+            }
83 85
         }
84 86
 
85 87
         if ($this->headers->get('Transfer-Encoding') != null) {
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Status.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
     public function set($code) {
50 50
 
51
-        if ( !$this->codes->exists($code) ) {
51
+        if (!$this->codes->exists($code)) {
52 52
 
53 53
             throw new Exception("Invalid HTTP Status Code $code");
54 54
 
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 
61 61
     }
62 62
 
63
-    public function description($code=null) {
63
+    public function description($code = null) {
64 64
 
65
-        if ( is_null($code) ) return $this->codes->getMessage($this->status_code);
65
+        if (is_null($code)) return $this->codes->getMessage($this->status_code);
66 66
         
67 67
         return $this->codes->getMessage($code);
68 68
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,9 @@
 block discarded – undo
62 62
 
63 63
     public function description($code=null) {
64 64
 
65
-        if ( is_null($code) ) return $this->codes->getMessage($this->status_code);
65
+        if ( is_null($code) ) {
66
+            return $this->codes->getMessage($this->status_code);
67
+        }
66 68
         
67 69
         return $this->codes->getMessage($code);
68 70
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status301.php 1 patch
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.
src/Comodojo/Dispatcher/Response/Preprocessor/Status100.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@
 block discarded – undo
28 28
 
29 29
     public function consolidate() {
30 30
 
31
-        $this->response->content>set(null);
32
-        $this->response->headers>delete('Content-Type');
33
-        $this->response->headers>delete('Content-Length');
31
+        $this->response->content > set(null);
32
+        $this->response->headers > delete('Content-Type');
33
+        $this->response->headers > delete('Content-Length');
34 34
 
35 35
     }
36 36
 
Please login to merge, or discard this patch.
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/Dispatcher.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->setTimestamp();
61 61
 
62 62
         // parsing configuration
63
-        $this->configuration = new Configuration( DefaultConfiguration::get() );
63
+        $this->configuration = new Configuration(DefaultConfiguration::get());
64 64
 
65 65
         $this->configuration->merge($configuration);
66 66
 
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 
92 92
         $this->logger->debug("Emitting global dispatcher event.");
93 93
 
94
-        $this->events->emit( new DispatcherEvent($this) );
94
+        $this->events->emit(new DispatcherEvent($this));
95 95
 
96
-        if ( $this->configuration->get('enabled') === false ) {
96
+        if ($this->configuration->get('enabled') === false) {
97 97
 
98 98
             $this->logger->debug("Dispatcher disabled, shutting down gracefully.");
99 99
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 
110 110
         }
111 111
 
112
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request') );
112
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request'));
113 113
 
114
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method->get()) );
114
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method->get()));
115 115
 
116
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') );
116
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.#'));
117 117
 
118
-        if ( $this->readCache() ) {
118
+        if ($this->readCache()) {
119 119
 
120 120
             return $this->shutdown();
121 121
 
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 
146 146
         $this->logger->debug("Route acquired, type $route_type directed to $route_service.");
147 147
 
148
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route') );
148
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route'));
149 149
 
150
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type) );
150
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_type));
151 151
 
152
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service) );
152
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$route_service));
153 153
 
154
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') );
154
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.#'));
155 155
 
156 156
         // translate route to service
157 157
 
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
     private function readCache() {
181 181
 
182
-        $name = (string) $this->request->uri;
182
+        $name = (string)$this->request->uri;
183 183
 
184 184
         $cache = $this->cache->setNamespace('dispatcherservice')->get($name);
185 185
 
186
-        if ( is_null($cache) ) return false;
186
+        if (is_null($cache)) return false;
187 187
 
188 188
         $this->response->import($cache);
189 189
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
         $cache = strtoupper($route->getParameter('cache'));
197 197
         $ttl = $route->getParameter('ttl');
198
-        $name = (string) $this->request->uri;
198
+        $name = (string)$this->request->uri;
199 199
         $method = $this->request->method->get();
200 200
         $status = $this->response->status->get();
201 201
 
@@ -203,10 +203,10 @@  discard block
 block discarded – undo
203 203
         //        because of dispatcher internal structure: if post request is cached
204 204
         //        subsequent requests will never reach the service.
205 205
         if (
206
-            ( $cache == 'SERVER' || $cache == 'BOTH' ) &&
206
+            ($cache == 'SERVER' || $cache == 'BOTH') &&
207 207
             in_array($request->method->get(), array('GET', 'HEAD')) &&
208 208
             in_array($this->status->get(), array(200, 203, 300, 301, 302, 404, 410))
209
-        ){
209
+        ) {
210 210
 
211 211
             $this->cache->setNamespace('dispatcherservice')->set($name, $this->response->export(), $ttl);
212 212
 
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 
219 219
         $params = $route->getParameter('headers');
220 220
 
221
-        if ( !empty($params) && is_array($params) ) {
221
+        if (!empty($params) && is_array($params)) {
222 222
 
223
-            foreach($params as $name=>$value) $this->response->headers->set($name, $value);
223
+            foreach ($params as $name=>$value) $this->response->headers->set($name, $value);
224 224
         }
225 225
 
226 226
     }
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 
261 261
         $this->response->consolidate($this->request, $this->route);
262 262
 
263
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response') );
263
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response'));
264 264
 
265
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status->get()) );
265
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status->get()));
266 266
 
267
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') );
267
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.#'));
268 268
 
269 269
         $this->logger->debug("Composing return value.");
270 270
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 
273 273
         $this->logger->debug("Dispatcher run-cycle ends.");
274 274
 
275
-        if ( function_exists('fastcgi_finish_request') ) fastcgi_finish_request();
275
+        if (function_exists('fastcgi_finish_request')) fastcgi_finish_request();
276 276
         else ob_end_clean();
277 277
 
278 278
         return $return;
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -183,7 +183,9 @@  discard block
 block discarded – undo
183 183
 
184 184
         $cache = $this->cache->setNamespace('dispatcherservice')->get($name);
185 185
 
186
-        if ( is_null($cache) ) return false;
186
+        if ( is_null($cache) ) {
187
+            return false;
188
+        }
187 189
 
188 190
         $this->response->import($cache);
189 191
 
@@ -220,7 +222,9 @@  discard block
 block discarded – undo
220 222
 
221 223
         if ( !empty($params) && is_array($params) ) {
222 224
 
223
-            foreach($params as $name=>$value) $this->response->headers->set($name, $value);
225
+            foreach($params as $name=>$value) {
226
+                $this->response->headers->set($name, $value);
227
+            }
224 228
         }
225 229
 
226 230
     }
@@ -272,8 +276,11 @@  discard block
 block discarded – undo
272 276
 
273 277
         $this->logger->debug("Dispatcher run-cycle ends.");
274 278
 
275
-        if ( function_exists('fastcgi_finish_request') ) fastcgi_finish_request();
276
-        else ob_end_clean();
279
+        if ( function_exists('fastcgi_finish_request') ) {
280
+            fastcgi_finish_request();
281
+        } else {
282
+            ob_end_clean();
283
+        }
277 284
 
278 285
         return $return;
279 286
 
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
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 
62 62
         $status = $this->response->status->get();
63 63
 
64
-        if ( !$this->codes->exists($status) ) throw new Exception("Invalid HTTP status code in response");
64
+        if (!$this->codes->exists($status)) throw new Exception("Invalid HTTP status code in response");
65 65
 
66 66
         $message = $this->codes->getMessage($status);
67 67
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,9 @@
 block discarded – undo
61 61
 
62 62
         $status = $this->response->status->get();
63 63
 
64
-        if ( !$this->codes->exists($status) ) throw new Exception("Invalid HTTP status code in response");
64
+        if ( !$this->codes->exists($status) ) {
65
+            throw new Exception("Invalid HTTP status code in response");
66
+        }
65 67
 
66 68
         $message = $this->codes->getMessage($status);
67 69
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Components/CacheManager.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -35,25 +35,25 @@  discard block
 block discarded – undo
35 35
 
36 36
         $cache = $this->configuration->get('cache');
37 37
 
38
-        if ( empty($cache) ) {
38
+        if (empty($cache)) {
39 39
 
40 40
             $manager = new ComodojoCacheManager(self::getAlgorithm(), $this->logger);
41 41
 
42 42
         } else {
43 43
 
44
-            $enabled = ( empty($cache['enabled']) || $cache['enabled'] === true ) ? true : false;
44
+            $enabled = (empty($cache['enabled']) || $cache['enabled'] === true) ? true : false;
45 45
 
46
-            $algorithm = self::getAlgorithm( empty($cache['algorithm']) ? null : $cache['algorithm']);
46
+            $algorithm = self::getAlgorithm(empty($cache['algorithm']) ? null : $cache['algorithm']);
47 47
 
48 48
             $manager = new ComodojoCacheManager($algorithm, $this->logger);
49 49
 
50
-            if ( $enabled && !empty($cache['providers']) ) {
50
+            if ($enabled && !empty($cache['providers'])) {
51 51
 
52 52
                 foreach ($cache['providers'] as $provider => $parameters) {
53 53
 
54 54
                     $handler = $this->getHandler($provider, $parameters);
55 55
 
56
-                    if ( $handler instanceof CacheInterface ) $manager->addProvider($handler);
56
+                    if ($handler instanceof CacheInterface) $manager->addProvider($handler);
57 57
 
58 58
                 }
59 59
 
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 
81 81
     protected function getHandler($provider, $parameters) {
82 82
 
83
-        switch ( strtolower($parameters['type']) ) {
83
+        switch (strtolower($parameters['type'])) {
84 84
 
85 85
             case 'filecache':
86 86
 
87 87
                 $base = $this->configuration->get('base-path');
88 88
 
89
-                if ( empty($parameters['folder']) ||  empty($base) ) {
89
+                if (empty($parameters['folder']) || empty($base)) {
90 90
                     $this->logger->warning("Wrong cache provider, disabling $provider", $parameters);
91 91
                     break;
92 92
                 }
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
             case 'memcached':
101 101
 
102
-                if ( empty($parameters['host']) ) {
102
+                if (empty($parameters['host'])) {
103 103
                     $this->logger->warning("Wrong cache provider, disabling $provider", $parameters);
104 104
                     break;
105 105
                 }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     protected static function getAlgorithm($algorithm = null) {
134 134
 
135
-        switch ( strtoupper($algorithm) ) {
135
+        switch (strtoupper($algorithm)) {
136 136
 
137 137
             case 'PICK_LAST':
138 138
                 $selected = ComodojoCacheManager::PICK_LAST;
Please login to merge, or discard this patch.