Completed
Pull Request — master (#4)
by Marco
03:31
created
src/Comodojo/Dispatcher/Traits/HeadersTrait.php 1 patch
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function get($header = null) {
41 41
 
42
-        if (is_null($header)) {
42
+        if ( is_null($header) ) {
43 43
             return $this->headers;
44 44
         }
45 45
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function getAsString($header = null) {
63 63
 
64
-        if (is_null($header)) {
64
+        if ( is_null($header) ) {
65 65
 
66 66
             return array_map([$this, 'headerToString'],
67 67
                 array_keys($this->headers),
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function set($header, $value = null) {
105 105
 
106
-        if (is_null($value)) {
106
+        if ( is_null($value) ) {
107 107
 
108 108
             $header = explode(":", $header, 2);
109 109
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function delete($header = null) {
133 133
 
134
-        if (is_null($header)) {
134
+        if ( is_null($header) ) {
135 135
 
136 136
             $this->headers = [];
137 137
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function merge($headers) {
160 160
 
161
-        foreach ($headers as $key => $value) {
161
+        foreach ( $headers as $key => $value ) {
162 162
             $this->set($key, $value);
163 163
         }
164 164
 
@@ -183,8 +183,7 @@  discard block
 block discarded – undo
183 183
     private static function headerToString($header, $value) {
184 184
 
185 185
         return is_array($value) ?
186
-            (string)("$header: ".implode(',',$value)) :
187
-            (string)("$header: $value");
186
+            (string)("$header: ".implode(',', $value)) : (string)("$header: $value");
188 187
 
189 188
     }
190 189
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Cache/ServerCache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         Response $response
70 70
     ) {
71 71
 
72
-        if ($this->bypass === true) {
72
+        if ( $this->bypass === true ) {
73 73
             return false;
74 74
         }
75 75
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
             ->setNamespace(self::$cache_namespace)
79 79
             ->get($name);
80 80
 
81
-        if (is_null($cache_object)) {
81
+        if ( is_null($cache_object) ) {
82 82
             return false;
83 83
         }
84 84
 
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Cache/RouterCache.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
      * @return int $ttl
57 57
      * @return bool
58 58
      */
59
-    public function dump($data, $ttl=null) {
59
+    public function dump($data, $ttl = null) {
60 60
 
61 61
         return $this->getCache()
62 62
             ->setNamespace(self::CACHE_NAMESPACE)
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Model.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -184,25 +184,25 @@  discard block
 block discarded – undo
184 184
 
185 185
     public function import($data) {
186 186
 
187
-        if (isset($data->headers)) $this->setHeaders($data->headers);
188
-        if (isset($data->status)) $this->setStatus($data->status);
189
-        if (isset($data->content)) $this->setContent($data->content);
190
-        if (isset($data->location)) $this->setLocation($data->location);
187
+        if ( isset($data->headers) ) $this->setHeaders($data->headers);
188
+        if ( isset($data->status) ) $this->setStatus($data->status);
189
+        if ( isset($data->content) ) $this->setContent($data->content);
190
+        if ( isset($data->location) ) $this->setLocation($data->location);
191 191
 
192
-        if (isset($data->cookies) && is_array($data->cookies)) {
192
+        if ( isset($data->cookies) && is_array($data->cookies) ) {
193 193
             $cookies = $this->getCookies();
194
-            foreach ($data->cookies as $name => $cookie) $cookies->add($cookie);
194
+            foreach ( $data->cookies as $name => $cookie ) $cookies->add($cookie);
195 195
         }
196 196
 
197 197
     }
198 198
 
199
-    public function consolidate(Request $request, Route $route=null) {
199
+    public function consolidate(Request $request, Route $route = null) {
200 200
 
201 201
         $status = $this->getStatus()->get();
202 202
         $preprocessor = $this->getPreprocessor()->get($status);
203 203
         $preprocessor->consolidate($this);
204 204
 
205
-        if ($route != null) {
205
+        if ( $route != null ) {
206 206
             $this->setClientCache($request, $route);
207 207
         }
208 208
 
@@ -210,19 +210,19 @@  discard block
 block discarded – undo
210 210
         $content = $this->getContent();
211 211
         $headers = $this->getHeaders();
212 212
 
213
-        if ((string)$request->getMethod() == 'HEAD' && !in_array($status, self::$no_content_statuses)) {
213
+        if ( (string)$request->getMethod() == 'HEAD' && !in_array($status, self::$no_content_statuses) ) {
214 214
             $length = $content->length();
215 215
             $content->set(null);
216
-            if ($length) {
216
+            if ( $length ) {
217 217
                 $headers->set('Content-Length', $length);
218 218
             }
219 219
         }
220 220
 
221
-        if ($headers->get('Transfer-Encoding') != null) {
221
+        if ( $headers->get('Transfer-Encoding') != null ) {
222 222
             $headers->delete('Content-Length');
223 223
         }
224 224
 
225
-        if ((string)$request->getVersion() == '1.0' && false !== strpos($headers->get('Cache-Control'), 'no-cache')) {
225
+        if ( (string)$request->getVersion() == '1.0' && false !== strpos($headers->get('Cache-Control'), 'no-cache') ) {
226 226
             $headers->set('pragma', 'no-cache');
227 227
             $headers->set('expires', -1);
228 228
         }
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
         ) {
244 244
 
245 245
             $headers = $this->getHeaders();
246
-            $timestamp = (int) $this->getTime()->format('U')+$ttl;
246
+            $timestamp = (int)$this->getTime()->format('U')+$ttl;
247 247
 
248
-            if ($ttl > 0) {
248
+            if ( $ttl > 0 ) {
249 249
 
250 250
                 $headers->set("Cache-Control", "max-age=".$ttl.", must-revalidate");
251 251
                 $headers->set("Expires", gmdate("D, d M Y H:i:s", $timestamp)." GMT");
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status201.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 
30 30
         $location = $response->getLocation()->get();
31 31
 
32
-        if ($location != null) {
32
+        if ( $location != null ) {
33 33
             $response->getHeaders()
34 34
                 ->set("Location", $location);
35 35
         }
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status405.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
         // @NOTE Allow Header should be provided by DispatcherException
32 32
         $allow = $response->getHeaders()->get('Allow');
33 33
 
34
-        if (empty($allow)) {
34
+        if ( empty($allow) ) {
35 35
             throw new Exception("Missing Allow header");
36 36
         }
37 37
 
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 = $response->getContent()->type();
34 34
         $charset = $response->getContent()->charset();
35 35
 
36
-        if (empty($charset)) {
36
+        if ( empty($charset) ) {
37 37
             $response->getHeaders()->set("Content-type", strtolower($type));
38 38
         } else {
39 39
             $response->getHeaders()->set("Content-type", strtolower($type)."; charset=".$charset);
Please login to merge, or discard this patch.
src/Comodojo/Dispatcher/Response/Preprocessor/Status205.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
             'Last-Modified'
38 38
         ];
39 39
 
40
-        foreach ($cleanup as $header) {
40
+        foreach ( $cleanup as $header ) {
41 41
             $response->getHeaders()
42 42
                 ->delete($header);
43 43
         }
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
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         $location = $response->getLocation()->get();
32 32
 
33
-        if (empty($location)) {
33
+        if ( empty($location) ) {
34 34
             throw new Exception("Invalid location, cannot redirect");
35 35
         }
36 36
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
         $content = $response->getContent();
40 40
 
41
-        if (empty($content->get())) {
41
+        if ( empty($content->get()) ) {
42 42
 
43 43
             $content->set(sprintf('<!DOCTYPE html>
44 44
 <html>
Please login to merge, or discard this patch.