Completed
Push — 4.0 ( e1271d...6e7e32 )
by Marco
14:12
created
src/Comodojo/Dispatcher/Dispatcher.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -167,6 +167,9 @@
 block discarded – undo
167 167
 
168 168
     }
169 169
 
170
+    /**
171
+     * @param string $name
172
+     */
170 173
     private function emitServiceSpecializedEvents($name) {
171 174
 
172 175
         return new ServiceEvent(
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 
147 147
     public function dispatch() {
148 148
 
149
-        $this->events->emit( new DispatcherEvent($this) );
149
+        $this->events->emit(new DispatcherEvent($this));
150 150
 
151
-        if ( $this->configuration()->get('dispatcher-enabled') === false ) {
151
+        if ($this->configuration()->get('dispatcher-enabled') === false) {
152 152
 
153 153
             $status = $this->configuration()->get('dispatcher-disabled-status');
154 154
 
@@ -162,11 +162,11 @@  discard block
 block discarded – undo
162 162
 
163 163
         }
164 164
 
165
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request') );
165
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request'));
166 166
 
167
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method()->get()) );
167
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.'.$this->request->method()->get()));
168 168
 
169
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.request.#') );
169
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.request.#'));
170 170
 
171 171
         try {
172 172
 
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
 
175 175
         } catch (DispatcherException $de) {
176 176
 
177
-            $this->response()->status()->set( $de->getStatus() );
177
+            $this->response()->status()->set($de->getStatus());
178 178
 
179
-            $this->response()->content()->set( $de->getMessage() );
179
+            $this->response()->content()->set($de->getMessage());
180 180
 
181 181
             return $this->shutdown();
182 182
 
183 183
         }
184 184
 
185
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route') );
185
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route'));
186 186
 
187
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getType()) );
187
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getType()));
188 188
 
189
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getService()) );
189
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.'.$this->router->getService()));
190 190
 
191
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.route.#') );
191
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.route.#'));
192 192
 
193 193
         // translate route to service
194 194
 
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 
199 199
         } catch (DispatcherException $de) {
200 200
 
201
-            $this->response()->status()->set( $de->getStatus() );
201
+            $this->response()->status()->set($de->getStatus());
202 202
 
203
-            $this->response()->content()->set( $de->getMessage() );
203
+            $this->response()->content()->set($de->getMessage());
204 204
 
205 205
         }
206 206
 
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 
224 224
     private function shutdown() {
225 225
 
226
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response') );
226
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response'));
227 227
 
228
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status()->get()) );
228
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.'.$this->response->status()->get()));
229 229
 
230
-        $this->events->emit( $this->emitServiceSpecializedEvents('dispatcher.response.#') );
230
+        $this->events->emit($this->emitServiceSpecializedEvents('dispatcher.response.#'));
231 231
 
232 232
         $return = Processor::parse($this->configuration, $this->logger, $this->response);
233 233
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             'dispatcher-log-level' => 'INFO',
249 249
             'dispatcher-log-target' => '%dispatcher-log-folder%/dispatcher.log',
250 250
             'dispatcher-log-folder' => '/log',
251
-            'dispatcher-supported-methods' => array('GET','PUT','POST','DELETE','OPTIONS','HEAD'),
251
+            'dispatcher-supported-methods' => array('GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD'),
252 252
             'dispatcher-default-encoding' => 'UTF-8',
253 253
             'dispatcher-cache-enabled' => true,
254 254
             'dispatcher-cache-ttl' => 3600,
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
 
265 265
     private static function urlGetAbsolute() {
266 266
 
267
-        $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
267
+        $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://';
268 268
 
269 269
         $uri = preg_replace("/\/index.php(.*?)$/i", "", $_SERVER['PHP_SELF']);
270 270
 
271
-        return ( $http . $_SERVER['HTTP_HOST'] . $uri . "/" );
271
+        return ($http.$_SERVER['HTTP_HOST'].$uri."/");
272 272
 
273 273
     }
274 274
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Router/Collector.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -209,6 +209,9 @@
 block discarded – undo
209 209
 
210 210
     }
211 211
 
212
+    /**
213
+     * @param string[] $bits
214
+     */
212 215
     private function evalUri($parameters, $bits) {
213 216
 
214 217
         $count  = 0;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
         foreach ($this->table->routes() as $regex => $value) {
190 190
 
191
-            if (preg_match("/" . $regex . "/", $path, $matches)) {
191
+            if (preg_match("/".$regex."/", $path, $matches)) {
192 192
 
193 193
                 $this->evalUri($value['query'], $matches);
194 194
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
                 $this->classname  = $value['class'];
202 202
                 $this->type       = $value['type'];
203 203
                 $this->service    = implode('.', $value['service']);
204
-                $this->service    = empty($this->service)?"default":$this->service;
204
+                $this->service    = empty($this->service) ? "default" : $this->service;
205 205
 
206 206
                 return true;
207 207
 
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
 
216 216
     private function evalUri($parameters, $bits) {
217 217
 
218
-        $count  = 0;
218
+        $count = 0;
219 219
 
220 220
         foreach ($parameters as $key => $value) {
221 221
 
222 222
             if (isset($bits[$key])) {
223 223
 
224
-                if (preg_match('/^' . $value['regex'] . '$/', $bits[$key], $matches)) {
224
+                if (preg_match('/^'.$value['regex'].'$/', $bits[$key], $matches)) {
225 225
 
226 226
                     if (count($matches) == 1) $matches = $matches[0];
227 227
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@  discard block
 block discarded – undo
96 96
                 $this->response
97 97
             );
98 98
             
99
+        } else {
100
+            return null;
99 101
         }
100
-        else return null;
101 102
         
102 103
     }
103 104
 
@@ -183,7 +184,9 @@  discard block
 block discarded – undo
183 184
                 
184 185
                 if (preg_match('/' . $value['regex'] . '/', $bits[$key], $matches)) {
185 186
                     
186
-                    if (count($matches) == 1) $matches = $matches[0];
187
+                    if (count($matches) == 1) {
188
+                        $matches = $matches[0];
189
+                    }
187 190
                     
188 191
                     $this->request->query()->set($key, $matches);
189 192
                     
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Cache/DispatcherCache.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         
42 42
         $ttl = $configuration->get('dispatcher-cache-ttl');
43 43
         
44
-        if ( $ttl !== null && !defined('COMODOJO_CACHE_DEFAULT_TTL') ) {
44
+        if ($ttl !== null && !defined('COMODOJO_CACHE_DEFAULT_TTL')) {
45 45
             
46 46
             define('COMODOJO_CACHE_DEFAULT_TTL', $ttl);
47 47
             
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
         
50 50
         $folder = $configuration->get('dispatcher-cache-folder');
51 51
         
52
-        $algorithm = self::getAlgorithm( $configuration->get('dispatcher-cache-algorithm') );
52
+        $algorithm = self::getAlgorithm($configuration->get('dispatcher-cache-algorithm'));
53 53
     
54
-        $manager = new CacheManager( $algorithm );
54
+        $manager = new CacheManager($algorithm);
55 55
         
56
-        if ( $enabled === true ) {
56
+        if ($enabled === true) {
57 57
             
58
-            $manager->addProvider( new FileCache($folder) );
58
+            $manager->addProvider(new FileCache($folder));
59 59
             
60 60
         }
61 61
         
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected static function getAlgorithm($algorithm) {
74 74
 
75
-        switch ( strtoupper($algorithm) ) {
75
+        switch (strtoupper($algorithm)) {
76 76
 
77 77
             case 'PICK_LAST':
78 78
                 $selected = CacheManager::PICK_LAST;
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Components/Parameters.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
     protected $parameters = array();
28 28
 
29
-    final public function get($parameter=null) {
29
+    final public function get($parameter = null) {
30 30
 
31
-        if ( is_null($parameter) ) return $this->parameters;
31
+        if (is_null($parameter)) return $this->parameters;
32 32
 
33
-        else if ( array_key_exists($parameter, $this->parameters) ) {
33
+        else if (array_key_exists($parameter, $this->parameters)) {
34 34
 
35 35
             return $this->parameters[$parameter];
36 36
 
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 
51 51
     final public function unset($parameter = null) {
52 52
 
53
-        if ( is_null($parameter) ) {
53
+        if (is_null($parameter)) {
54 54
 
55 55
             $this->parameters = array();
56 56
 
57 57
             return true;
58 58
 
59
-        } else if ( array_key_exists($parameter, $this->parameters) ) {
59
+        } else if (array_key_exists($parameter, $this->parameters)) {
60 60
 
61 61
             unset($this->parameters[$parameter]);
62 62
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@
 block discarded – undo
28 28
 
29 29
     final public function get($parameter=null) {
30 30
 
31
-        if ( is_null($parameter) ) return $this->parameters;
32
-
33
-        else if ( array_key_exists($parameter, $this->parameters) ) {
31
+        if ( is_null($parameter) ) {
32
+            return $this->parameters;
33
+        } else if ( array_key_exists($parameter, $this->parameters) ) {
34 34
 
35 35
             return $this->parameters[$parameter];
36 36
 
37
+        } else {
38
+            return null;
37 39
         }
38 40
 
39
-        else return null;
40
-
41 41
     }
42 42
 
43 43
     final public function set($parameter, $value) {
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Log/DispatcherLogger.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -43,19 +43,19 @@  discard block
 block discarded – undo
43 43
         
44 44
         $enabled = $configuration->get('dispatcher-log-enabled');
45 45
         
46
-        $level = self::getLevel( $configuration->get('dispatcher-log-level') );
46
+        $level = self::getLevel($configuration->get('dispatcher-log-level'));
47 47
         
48 48
         $target = $configuration->get('dispatcher-log-target');
49 49
     
50 50
         $logger = new Logger($name);
51 51
         
52
-        if ( $enabled === true ) {
52
+        if ($enabled === true) {
53 53
             
54
-            $logger->pushHandler( new StreamHandler( $target, $level) );
54
+            $logger->pushHandler(new StreamHandler($target, $level));
55 55
             
56 56
         } else {
57 57
             
58
-            $logger->pushHandler( new NullHandler($level) );
58
+            $logger->pushHandler(new NullHandler($level));
59 59
             
60 60
         }
61 61
         
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     protected static function getLevel($level) {
74 74
 
75
-        switch ( strtoupper($level) ) {
75
+        switch (strtoupper($level)) {
76 76
 
77 77
             case 'INFO':
78 78
                 $logger_level = Logger::INFO;
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Output/Processor.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
                 break;
177 177
 
178 178
             /**
179
-            * @todo: how to get reverse allowed methods reference?
180
-            */
179
+             * @todo: how to get reverse allowed methods reference?
180
+             */
181 181
             // case 405: //Not allowed
182 182
             //
183 183
             // header('Allow: ' . $value, true, 405);
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
                 break;
193 193
 
194 194
             /**
195
-            * @todo: how to get reverse allowed methods reference?
196
-            */
195
+             * @todo: how to get reverse allowed methods reference?
196
+             */
197 197
             // case 501: //Not implemented
198 198
             //
199 199
             // header('Allow: ' . $value, true, 501);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
                 header($_SERVER["SERVER_PROTOCOL"].' 204 No Content');
117 117
                 header('Status: 204 No Content');
118
-                header('Content-Length: 0',true);
118
+                header('Content-Length: 0', true);
119 119
 
120 120
                 $return = null;
121 121
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             case 303: //See Other
128 128
             case 307: //Temporary Redirect
129 129
 
130
-                header("Location: ".$location->get(),true,$status);
130
+                header("Location: ".$location->get(), true, $status);
131 131
 
132 132
                 break;
133 133
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 
136 136
                 $last_modified = $headers->get('Last-Modified');
137 137
 
138
-                if ( is_null($last_modified) ) {
138
+                if (is_null($last_modified)) {
139 139
 
140 140
                     header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified');
141 141
 
142
-                } else if ( is_int($last_modified) ) {
142
+                } else if (is_int($last_modified)) {
143 143
 
144 144
                     header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT', true, 304);
145 145
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Request/Headers.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,13 +41,13 @@
 block discarded – undo
41 41
      */
42 42
     private static function getHeaders() {
43 43
 
44
-        if ( function_exists('getallheaders') ) return getallheaders();
44
+        if (function_exists('getallheaders')) return getallheaders();
45 45
 
46 46
         $headers = array();
47 47
 
48
-        foreach ( $_SERVER as $name => $value ) {
48
+        foreach ($_SERVER as $name => $value) {
49 49
 
50
-            if ( substr($name, 0, 5) == 'HTTP_' ) {
50
+            if (substr($name, 0, 5) == 'HTTP_') {
51 51
 
52 52
                 $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
53 53
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,9 @@
 block discarded – undo
41 41
      */
42 42
     private static function getHeaders() {
43 43
 
44
-        if ( function_exists('getallheaders') ) return getallheaders();
44
+        if ( function_exists('getallheaders') ) {
45
+            return getallheaders();
46
+        }
45 47
 
46 48
         $headers = array();
47 49
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Request/Post.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 
47 47
     private static function getParameters() {
48 48
 
49
-        switch( $_SERVER['REQUEST_METHOD'] ) {
49
+        switch ($_SERVER['REQUEST_METHOD']) {
50 50
 
51 51
             case 'POST':
52 52
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Request/Query.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 
47 47
     private static function getParameters() {
48 48
 
49
-        switch( $_SERVER['REQUEST_METHOD'] ) {
49
+        switch ($_SERVER['REQUEST_METHOD']) {
50 50
 
51 51
             case 'POST':
52 52
 
Please login to merge, or discard this patch.