Completed
Push — 4.0 ( 937edb...4d6b64 )
by Marco
09:04
created
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/Router/Parser.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -103,7 +103,9 @@
 block discarded – undo
103 103
                      */
104 104
                     $param_regex .= $this->param($key, $string, $value);
105 105
                     
106
-                    if ($value->isQueryRequired($key)) $param_required = true;
106
+                    if ($value->isQueryRequired($key)) {
107
+                        $param_required = true;
108
+                    }
107 109
 
108 110
                     $this->logger->debug("PARAMETER REGEX: " . $param_regex);
109 111
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
                  */
87 87
                 foreach ($decoded as $key => $string) {
88 88
 
89
-                    $this->logger->debug("PARAMETER KEY: " . $key);
89
+                    $this->logger->debug("PARAMETER KEY: ".$key);
90 90
 
91
-                    $this->logger->debug("PARAMETER STRING: " . $string);
91
+                    $this->logger->debug("PARAMETER STRING: ".$string);
92 92
 
93 93
                     /* The key and the regex of every paramater is passed to the 'param'
94 94
                      * method which will build an appropriate regular expression and will understand
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 
99 99
                     if ($value->isQueryRequired($key)) $param_required = true;
100 100
 
101
-                    $this->logger->debug("PARAMETER REGEX: " . $param_regex);
101
+                    $this->logger->debug("PARAMETER REGEX: ".$param_regex);
102 102
 
103 103
                 }
104 104
                 // Once the parameter is analyzed, the result is passed to the next iteration
105 105
                 return $this->read(
106 106
                     $folders,
107 107
                     $value,
108
-                    $regex.'(?:\/'.$param_regex.')'. (($param_required)?'{1}':'?')
108
+                    $regex.'(?:\/'.$param_regex.')'.(($param_required) ? '{1}' : '?')
109 109
                 );
110 110
 
111 111
             } else {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
          * If the field is required, the regular expression is completed with a '{1}' (which make it compulsory),
162 162
          * otherwise a '?' is added.
163 163
          */
164
-        return '(?P<' . $key . '>' . $string . ')' . (($field_required)?'{1}':'?');
164
+        return '(?P<'.$key.'>'.$string.')'.(($field_required) ? '{1}' : '?');
165 165
 
166 166
     }
167 167
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Components/DefaultConfiguration.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@
 block discarded – undo
48 48
 
49 49
     private static function urlGetAbsolute() {
50 50
 
51
-        $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
51
+        $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://';
52 52
 
53 53
         $uri = self::uriGetAbsolute();
54 54
 
55
-        return ( $http . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') . $uri . "/" );
55
+        return ($http.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost').$uri."/");
56 56
 
57 57
     }
58 58
 
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/Router/Model.php 2 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
         if (!$this->bypass_routing) {
107 107
 
108
-            if (!$this->parse()) throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404);
108
+            if (!$this->parse()) {
109
+                throw new DispatcherException("Unable to find a valid route for the specified uri", 0, null, 404);
110
+            }
109 111
 
110 112
         }
111 113
 
@@ -133,8 +135,9 @@  discard block
 block discarded – undo
133 135
                 $this->extra
134 136
             );
135 137
 
138
+        } else {
139
+            return null;
136 140
         }
137
-        else return null;
138 141
         
139 142
     }
140 143
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
         $methods = $this->configuration->get('allowed-http-methods');
90 90
 
91
-        if ( ( $methods != null || !empty($methods) ) && in_array($method, $methods) === false ) {
91
+        if (($methods != null || !empty($methods)) && in_array($method, $methods) === false) {
92 92
 
93 93
             throw new DispatcherException("Method not allowed", 0, null, 405, array(
94
-                "Allow" => implode(",",$methods)
94
+                "Allow" => implode(",", $methods)
95 95
             ));
96 96
 
97 97
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
         }
145 145
 
146
-        if ( $this->bypass_service ) {
146
+        if ($this->bypass_service) {
147 147
 
148 148
             return;
149 149
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
             $methods = $service->getImplementedMethods();
161 161
 
162
-            if ( in_array($method, $methods) ) {
162
+            if (in_array($method, $methods)) {
163 163
 
164 164
                 $callable = $service->getMethod($method);
165 165
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         foreach ($this->table->routes as $regex => $value) {
203 203
 
204 204
             // The current uri is checked against all the global regular expressions associated with the routes
205
-            if (preg_match("/" . $regex . "/", $path, $matches)) {
205
+            if (preg_match("/".$regex."/", $path, $matches)) {
206 206
 
207 207
                 /* If a route is matched, all the bits of the route string are evalued in order to create
208 208
                  * new query parameters which will be available for the service class
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/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.