Completed
Push — master ( ca8209...ce9662 )
by Marco
12:13
created
src/ObjectRoute/ObjectRoute.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 
48 48
     private $parameters = array();
49 49
 
50
-    private $supported_route_types = array("ROUTE","REDIRECT","ERROR");
50
+    private $supported_route_types = array("ROUTE", "REDIRECT", "ERROR");
51 51
 
52
-    private $supported_redirect_codes = array(201,301,302,303,307);
52
+    private $supported_redirect_codes = array(201, 301, 302, 303, 307);
53 53
 
54
-    private $supported_error_codes = array(400,403,404,405,500,501,503);
54
+    private $supported_error_codes = array(400, 403, 404, 405, 500, 501, 503);
55 55
 
56
-    private $supported_cache_modes = array("SERVER","CLIENT","BOTH");
56
+    private $supported_cache_modes = array("SERVER", "CLIENT", "BOTH");
57 57
 
58 58
     /**
59 59
      * Set service name
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      *
242 242
      * @return  ObjectRequest   $this
243 243
      */
244
-    public function setHeader($header, $value=null) {
244
+    public function setHeader($header, $value = null) {
245 245
 
246 246
         $this->headers[$header] = $value;
247 247
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     public function unsetHeader($header) {
260 260
 
261
-        if ( isset($this->headers[$header]) ) {
261
+        if (isset($this->headers[$header])) {
262 262
 
263 263
             unset($this->headers[$header]);
264 264
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public function getHeader($header) {
281 281
 
282
-        if ( isset($this->headers[$header]) ) return $this->headers[$header];
282
+        if (isset($this->headers[$header])) return $this->headers[$header];
283 283
 
284 284
         return null;
285 285
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
      *
330 330
      * @return  ObjectRequest   $this
331 331
      */
332
-    public function setParameter($parameter, $value=null) {
332
+    public function setParameter($parameter, $value = null) {
333 333
 
334 334
         $this->parameters[$parameter] = $value;
335 335
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      */
345 345
     public function getParameter($parameter) {
346 346
 
347
-        if ( isset($this->parameters[$parameter]) ) return $this->parameters[$parameter];
347
+        if (isset($this->parameters[$parameter])) return $this->parameters[$parameter];
348 348
 
349 349
         else return null;
350 350
 
Please login to merge, or discard this patch.
src/Dispatcher.php 1 patch
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
         // Starts composing request object (ObjectRequest)
183 183
 
184
-        list($request_service,$request_attributes) = $this->urlInterpreter($this->working_mode);
184
+        list($request_service, $request_attributes) = $this->urlInterpreter($this->working_mode);
185 185
 
186 186
         list($request_parameters, $request_raw_parameters) = $this->deserializeParameters($this->request_method);
187 187
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
         // Before composing the object request, remember to define the current (absolute) dispatcher baseurl
191 191
         // (if not specified in dispatcher-config)
192
-        if ( !defined("DISPATCHER_BASEURL") ) define("DISPATCHER_BASEURL",$this->urlGetAbsolute($request_service));
192
+        if (!defined("DISPATCHER_BASEURL")) define("DISPATCHER_BASEURL", $this->urlGetAbsolute($request_service));
193 193
 
194 194
         // Now let's compose request object
195 195
 
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
      * @param   array   $parameters (optional) Service options (cache, ...)
219 219
      * @param   bool    $relative   (optional) If true, target will be assumed in default service directory
220 220
      */
221
-    final public function setRoute($service, $type, $target, $parameters=Array(), $relative=true) {
221
+    final public function setRoute($service, $type, $target, $parameters = Array(), $relative = true) {
222 222
 
223 223
         try {
224 224
 
225
-            if ( strtoupper($type) == "ROUTE" ) {
225
+            if (strtoupper($type) == "ROUTE") {
226 226
 
227
-                if ( $relative ) $this->routingtable->setRoute($service, $type, DISPATCHER_SERVICES_FOLDER.$target, $parameters);
227
+                if ($relative) $this->routingtable->setRoute($service, $type, DISPATCHER_SERVICES_FOLDER.$target, $parameters);
228 228
 
229 229
                 else $this->routingtable->setRoute($service, $type, $target, $parameters);
230 230
 
231 231
             }
232 232
 
233
-            else if ( strtoupper($type) == "REDIRECT" ) {
233
+            else if (strtoupper($type) == "REDIRECT") {
234 234
 
235
-                if ( $relative ) $this->routingtable->setRoute($service, $type, DISPATCHER_BASEURL.$target, $parameters);
235
+                if ($relative) $this->routingtable->setRoute($service, $type, DISPATCHER_BASEURL.$target, $parameters);
236 236
 
237 237
                 else $this->routingtable->setRoute($service, $type, $target, $parameters);
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         } catch (Exception $e) {
244 244
 
245 245
             //debug error but do not stop dispatcher
246
-            $this->logger->warning( 'Unable to set route'.Array('SERVIVE' => $service) );
246
+            $this->logger->warning('Unable to set route'.Array('SERVIVE' => $service));
247 247
 
248 248
         }
249 249
 
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         } catch (Exception $e) {
266 266
 
267 267
             //debug error but do not stop dispatcher
268
-            $this->logger->warning( 'Unable to unset route'.Array('SERVIVE' => $service) );
268
+            $this->logger->warning('Unable to unset route'.Array('SERVIVE' => $service));
269 269
 
270 270
         }
271 271
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      * @param   string  $callback   The callback (or class if $method is specified)
279 279
      * @param   string  $method     (optional) Method for $callback
280 280
      */
281
-    final public function addHook($event, $callback, $method=null) {
281
+    final public function addHook($event, $callback, $method = null) {
282 282
 
283 283
         try {
284 284
 
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
         } catch (Exception $e) {
288 288
 
289 289
             //debug error but do not stop dispatcher
290
-            $this->logger->warning( 'Unable to add hook'.Array(
290
+            $this->logger->warning('Unable to add hook'.Array(
291 291
                 'CALLBACK' => $callback,
292 292
                 'METHOD' => $method,
293 293
                 'EVENT' => $event
294
-            ) );
294
+            ));
295 295
 
296 296
         }
297 297
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * @param   string  $event      The event name
304 304
      * @param   string  $callback   The callback (or class if $method is specified)
305 305
      */
306
-    final public function removeHook($event, $callback=null) {
306
+    final public function removeHook($event, $callback = null) {
307 307
 
308 308
         try {
309 309
 
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
         } catch (Exception $e) {
313 313
 
314 314
             //debug error but do not stop dispatcher
315
-            $this->logger->warning( 'Unable to remove hook'.Array(
315
+            $this->logger->warning('Unable to remove hook'.Array(
316 316
                 'CALLBACK' => $callback,
317 317
                 'EVENT' => $event
318
-            ) );
318
+            ));
319 319
 
320 320
         }
321 321
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
      * @param   string  $plugin     The plugin name
328 328
      * @param   string  $folder     (optional) plugin folder (if omitted, dispatcher will use default one)
329 329
      */
330
-    final public function loadPlugin($plugin, $folder=DISPATCHER_PLUGINS_FOLDER) {
330
+    final public function loadPlugin($plugin, $folder = DISPATCHER_PLUGINS_FOLDER) {
331 331
 
332 332
         include $folder.$plugin.".php";
333 333
 
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
      */
365 365
     final public function clearCache($all = null) {
366 366
 
367
-        return $this->cacher->purge( $all == true ? null : $this->service_url );
367
+        return $this->cacher->purge($all == true ? null : $this->service_url);
368 368
 
369 369
     }
370 370
 
@@ -380,26 +380,26 @@  discard block
 block discarded – undo
380 380
 
381 381
         $fork = $this->events->fire("dispatcher", "DISPATCHER", $this->enabled);
382 382
 
383
-        if ( is_bool($fork)  ) $this->enabled = $fork;
383
+        if (is_bool($fork)) $this->enabled = $fork;
384 384
 
385 385
         // After building dispatcher instance, fire THE level2 event "dispatcher.request"
386 386
         // This default hook will expose current request (ObjectRequest) to callbacks
387 387
 
388 388
         $fork = $this->events->fire("dispatcher.request", "REQUEST", $this->request);
389 389
 
390
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest ) $this->request = $fork;
390
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest) $this->request = $fork;
391 391
 
392 392
         // Fire level3 event "dispatcher.request.[method]"
393 393
         
394 394
         $fork = $this->events->fire("dispatcher.request.".$this->request_method, "REQUEST", $this->request);
395 395
 
396
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest ) $this->request = $fork;
396
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest) $this->request = $fork;
397 397
 
398 398
         // Fire level3 event "dispatcher.request.[service]"
399 399
         
400 400
         $fork = $this->events->fire("dispatcher.request.".$this->request->getService(), "REQUEST", $this->request);
401 401
 
402
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest ) $this->request = $fork;
402
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRequest\ObjectRequest) $this->request = $fork;
403 403
 
404 404
         // Fire special event, it will not modify request
405 405
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 
408 408
         // Check if dispatcher is enabled
409 409
 
410
-        if ( $this->enabled == false ) {
410
+        if ($this->enabled == false) {
411 411
 
412 412
             $route = new ObjectError();
413 413
             $route->setStatusCode(503);
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
         $fork = $this->events->fire("dispatcher.routingtable", "TABLE", $this->routingtable);
428 428
 
429
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRoutingTable\ObjectRoutingTable ) $this->routingtable = $fork;
429
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRoutingTable\ObjectRoutingTable) $this->routingtable = $fork;
430 430
 
431 431
         // Retrieve current route from routing table
432 432
 
@@ -443,34 +443,34 @@  discard block
 block discarded – undo
443 443
             ->setType($preroute["type"])
444 444
             ->setTarget($preroute["target"]);
445 445
 
446
-        if ( isset($preroute["parameters"]["class"]) ) {
446
+        if (isset($preroute["parameters"]["class"])) {
447 447
             $this->serviceroute->setClass($preroute["parameters"]["class"]);
448 448
         } else {
449 449
             $t = pathinfo($preroute["target"]);
450 450
             $this->serviceroute->setClass(preg_replace('/\\.[^.\\s]{3,4}$/', '', $t["filename"]));
451 451
         }
452 452
         
453
-        if ( isset($preroute["parameters"]["redirectCode"]) ) {
453
+        if (isset($preroute["parameters"]["redirectCode"])) {
454 454
             $this->serviceroute->setRedirectCode($preroute["parameters"]["redirectCode"]);
455 455
             unset($preroute["parameters"]["redirectCode"]);
456 456
         }
457
-        if ( isset($preroute["parameters"]["errorCode"]) ) {
457
+        if (isset($preroute["parameters"]["errorCode"])) {
458 458
             $this->serviceroute->setErrorCode($preroute["parameters"]["errorCode"]);
459 459
             unset($preroute["parameters"]["errorCode"]);
460 460
         }
461
-        if ( isset($preroute["parameters"]["cache"]) ) {
461
+        if (isset($preroute["parameters"]["cache"])) {
462 462
             $this->serviceroute->setCache($preroute["parameters"]["cache"]);
463 463
             unset($preroute["parameters"]["cache"]);
464 464
         }
465
-        if ( isset($preroute["parameters"]["ttl"]) ) {
465
+        if (isset($preroute["parameters"]["ttl"])) {
466 466
             $this->serviceroute->setTtl($preroute["parameters"]["ttl"]);
467 467
             unset($preroute["parameters"]["ttl"]);
468 468
         }
469
-        if ( isset($preroute["parameters"]["headers"]) ) {
470
-            if ( is_array($preroute["parameters"]["headers"]) ) foreach ($preroute["parameters"]["headers"] as $header => $value) $this->serviceroute->setHeader($header, $value);
469
+        if (isset($preroute["parameters"]["headers"])) {
470
+            if (is_array($preroute["parameters"]["headers"])) foreach ($preroute["parameters"]["headers"] as $header => $value) $this->serviceroute->setHeader($header, $value);
471 471
             unset($preroute["parameters"]["headers"]);
472 472
         }
473
-        if ( isset($preroute["parameters"]["accessControl"]) ) {
473
+        if (isset($preroute["parameters"]["accessControl"])) {
474 474
             $this->serviceroute->setRedirectCode($preroute["parameters"]["accessControl"]);
475 475
             unset($preroute["parameters"]["accessControl"]);
476 476
         }
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 
487 487
         $fork = $this->events->fire("dispatcher.serviceroute", "ROUTE", $this->serviceroute);
488 488
 
489
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute ) $this->serviceroute = $fork;
489
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute) $this->serviceroute = $fork;
490 490
 
491 491
         $fork = $this->events->fire("dispatcher.serviceroute.".$this->serviceroute->getType(), "ROUTE", $this->serviceroute);
492 492
 
493
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute ) $this->serviceroute = $fork;
493
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute) $this->serviceroute = $fork;
494 494
 
495 495
         $fork = $this->events->fire("dispatcher.serviceroute.".$this->serviceroute->getService(), "ROUTE", $this->serviceroute);
496 496
 
497
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute ) $this->serviceroute = $fork;
497
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectRoute\ObjectRoute) $this->serviceroute = $fork;
498 498
 
499 499
         // Fire special event, it will not modify route
500 500
 
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 
505 505
         $accesscontrol = preg_replace('/\s+/', '', $this->serviceroute->getAccessControl());
506 506
 
507
-        if ( $accesscontrol != null AND $accesscontrol != "*" ) {
507
+        if ($accesscontrol != null AND $accesscontrol != "*") {
508 508
 
509 509
             $origins = explode(",", $accesscontrol);
510 510
 
511
-            if ( !in_array(@$_SERVER['HTTP_ORIGIN'], $origins) ) {
511
+            if (!in_array(@$_SERVER['HTTP_ORIGIN'], $origins)) {
512 512
 
513 513
                 $route = new ObjectError();
514 514
                 $route->setStatusCode(403)->setContent("Origin not allowed");
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
             'REDIRECTCODE'  => $this->serviceroute->getRedirectCode()
536 536
         ));
537 537
 
538
-        switch($this->serviceroute->getType()) {
538
+        switch ($this->serviceroute->getType()) {
539 539
 
540 540
             case "ERROR":
541 541
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
             $uri = explode('/', $_SERVER['REQUEST_URI']);
621 621
             $scr = explode('/', $_SERVER['SCRIPT_NAME']);
622 622
 
623
-            for($i= 0;$i < sizeof($scr);$i++) {
623
+            for ($i = 0; $i < sizeof($scr); $i++) {
624 624
                 if ($uri[$i] == $scr[$i]) unset($uri[$i]);
625 625
             }
626 626
 
@@ -694,21 +694,21 @@  discard block
 block discarded – undo
694 694
      *
695 695
      * @return uri  The baseurl
696 696
      */
697
-    private function urlGetAbsolute($service=null) {
697
+    private function urlGetAbsolute($service = null) {
698 698
 
699
-        $http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
699
+        $http = 'http'.((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '').'://';
700 700
 
701
-        if ( is_null($service) ) $uri = "";
701
+        if (is_null($service)) $uri = "";
702 702
 
703 703
         else {
704 704
 
705 705
             $self = $_SERVER['PHP_SELF'];
706 706
 
707
-            $uri = preg_replace("/\/index.php(.*?)$/i","",$self);
707
+            $uri = preg_replace("/\/index.php(.*?)$/i", "", $self);
708 708
 
709 709
         }
710 710
 
711
-        return ( $http . $_SERVER['HTTP_HOST'] . $uri . "/" );
711
+        return ($http.$_SERVER['HTTP_HOST'].$uri."/");
712 712
 
713 713
     }
714 714
 
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 
733 733
         $parameters = Array();
734 734
 
735
-        switch($method) {
735
+        switch ($method) {
736 736
 
737 737
             case 'POST':
738 738
 
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 
756 756
     private function attributesMatch($provided, $expected, $liked) {
757 757
 
758
-        if ( $this->working_mode == "STANDARD" ) return $this->parametersMatch($provided, $expected, $liked);
758
+        if ($this->working_mode == "STANDARD") return $this->parametersMatch($provided, $expected, $liked);
759 759
 
760 760
         $attributes = Array();
761 761
 
@@ -763,9 +763,9 @@  discard block
 block discarded – undo
763 763
         $esize = sizeof($expected);
764 764
         $lsize = sizeof($liked);
765 765
 
766
-        if ( $psize < $esize ) throw new DispatcherException("Conversation error", 400);
766
+        if ($psize < $esize) throw new DispatcherException("Conversation error", 400);
767 767
 
768
-        else if ( $psize == $esize ) {
768
+        else if ($psize == $esize) {
769 769
 
770 770
             $attributes = $psize == 0 ? array() : array_combine($expected, $provided);
771 771
 
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 
774 774
         else {
775 775
 
776
-            if ( $esize == 0 ) {
776
+            if ($esize == 0) {
777 777
 
778 778
                 $e_attributes = array();
779 779
 
@@ -793,19 +793,19 @@  discard block
 block discarded – undo
793 793
 
794 794
             $l_attributes = Array();
795 795
 
796
-            if ( $lvaluessize < $lsize ) {
796
+            if ($lvaluessize < $lsize) {
797 797
 
798 798
                 $l_attributes = array_combine(array_slice($liked, 0, $lvaluessize), $lvalues);
799 799
 
800 800
             }
801
-            else if ( $lvaluessize == $lsize ) {
801
+            else if ($lvaluessize == $lsize) {
802 802
 
803 803
                 $l_attributes = $lvaluessize == 0 ? array() : array_combine($liked, $lvalues);
804 804
 
805 805
             }
806 806
             else {
807 807
 
808
-                if ( $lsize == 0 ) {
808
+                if ($lsize == 0) {
809 809
 
810 810
                     $l_attributes = $lvalues;
811 811
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 
834 834
         foreach ($expected as $parameter) {
835 835
 
836
-            if ( !isset($provided[$parameter]) ) throw new DispatcherException("Conversation error", 400);
836
+            if (!isset($provided[$parameter])) throw new DispatcherException("Conversation error", 400);
837 837
 
838 838
         }
839 839
 
@@ -851,11 +851,11 @@  discard block
 block discarded – undo
851 851
 
852 852
         // First of all, check cache (in case of GET request)
853 853
 
854
-        if ( $method == "GET" AND ( $cache == "SERVER" OR $cache == "BOTH" ) ) {
854
+        if ($method == "GET" AND ($cache == "SERVER" OR $cache == "BOTH")) {
855 855
 
856 856
             $from_cache = $this->cacher->get($this->service_url, $ttl);
857 857
 
858
-            if ( is_array($from_cache) ) {
858
+            if (is_array($from_cache)) {
859 859
 
860 860
                 $maxage = $from_cache["maxage"];
861 861
                 $bestbefore = $from_cache["bestbefore"];
@@ -873,13 +873,13 @@  discard block
 block discarded – undo
873 873
 
874 874
         // If there's no cache for this request, use routing information to find service
875 875
 
876
-        if ( (include($target)) === false ) throw new DispatcherException("Cannot run service", 500);
876
+        if ((include($target)) === false) throw new DispatcherException("Cannot run service", 500);
877 877
 
878 878
         // Find a service implementation and try to init it
879 879
 
880 880
         $service_class = $route->getClass();
881 881
 
882
-        if ( empty($service_class) ) throw new DispatcherException("Cannot run service", 500);
882
+        if (empty($service_class)) throw new DispatcherException("Cannot run service", 500);
883 883
 
884 884
         $service_class = "\\Comodojo\\Dispatcher\\Service\\".$service_class;
885 885
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 
900 900
         // Check if service supports current HTTP method
901 901
 
902
-        if ( !in_array($method, explode(",", $theservice->getSupportedMethods())) ) {
902
+        if (!in_array($method, explode(",", $theservice->getSupportedMethods()))) {
903 903
 
904 904
             throw new DispatcherException("Allow: ".$theservice->getSupportedMethods(), 405);
905 905
 
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 
908 908
         // Check if service implements current HTTP method
909 909
 
910
-        if ( !in_array($method, $theservice->getImplementedMethods()) ) {
910
+        if (!in_array($method, $theservice->getImplementedMethods())) {
911 911
 
912
-            throw new DispatcherException("Allow: ".implode(",",$theservice->getImplementedMethods()), 501);
912
+            throw new DispatcherException("Allow: ".implode(",", $theservice->getImplementedMethods()), 501);
913 913
 
914 914
         }
915 915
 
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
             $return->setService($service)
953 953
                 ->setStatusCode($theservice->getStatusCode())
954 954
                 ->setContent($result)
955
-                ->setHeaders( array_merge($theservice->getHeaders(), $route->getHeaders()) )
955
+                ->setHeaders(array_merge($theservice->getHeaders(), $route->getHeaders()))
956 956
                 ->setContentType($theservice->getContentType())
957 957
                 ->setCharset($theservice->getCharset());
958 958
             
@@ -982,15 +982,15 @@  discard block
 block discarded – undo
982 982
         // This means event engine will fire a dispatcher.[routetype] event
983 983
         // In case of wrong instance, create an ObjectError (500, null) instance
984 984
 
985
-        if ( $route instanceof ObjectSuccess ) {
985
+        if ($route instanceof ObjectSuccess) {
986 986
 
987 987
             $hook = "dispatcher.route";
988 988
 
989
-        } else if ( $route instanceof ObjectError ) {
989
+        } else if ($route instanceof ObjectError) {
990 990
 
991 991
             $hook = "dispatcher.error";
992 992
 
993
-        } else if ( $route instanceof ObjectRedirect ) {
993
+        } else if ($route instanceof ObjectRedirect) {
994 994
 
995 995
             $hook = "dispatcher.redirect";
996 996
 
@@ -1006,13 +1006,13 @@  discard block
 block discarded – undo
1006 1006
 
1007 1007
         $fork = $this->events->fire("dispatcher.result", "RESULT", $route);
1008 1008
 
1009
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface ) $route = $fork;
1009
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) $route = $fork;
1010 1010
 
1011 1011
         // Fire second hook (level2), as specified above
1012 1012
 
1013 1013
         $fork = $this->events->fire($hook, "RESULT", $route);
1014 1014
 
1015
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface ) $route = $fork;
1015
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) $route = $fork;
1016 1016
 
1017 1017
         // Now select and fire last hook (level3)
1018 1018
         // This means that event engine will fire something like "dispatcher.route.200"
@@ -1020,13 +1020,13 @@  discard block
 block discarded – undo
1020 1020
 
1021 1021
         $fork = $this->events->fire($hook.".".$route->getStatusCode(), "RESULT", $route);
1022 1022
 
1023
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface ) $route = $fork;
1023
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) $route = $fork;
1024 1024
 
1025 1025
         // Fire special event, it may modify result
1026 1026
 
1027 1027
         $fork = $this->events->fire("dispatcher.result.#", "RESULT", $route);
1028 1028
 
1029
-        if ( $fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface ) $route = $fork;
1029
+        if ($fork instanceof \Comodojo\Dispatcher\ObjectResult\ObjectResultInterface) $route = $fork;
1030 1030
 
1031 1031
         // After hooks:
1032 1032
         // - store cache
@@ -1035,10 +1035,10 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
         $cache = $route instanceof \Comodojo\Dispatcher\ObjectResult\ObjectSuccess ? $this->serviceroute->getCache() : null;
1037 1037
 
1038
-        if ( $this->request_method == "GET" AND 
1039
-            ( $cache == "SERVER" OR $cache == "BOTH" ) AND
1038
+        if ($this->request_method == "GET" AND 
1039
+            ($cache == "SERVER" OR $cache == "BOTH") AND
1040 1040
             $this->result_comes_from_cache == false AND 
1041
-            $route instanceof \Comodojo\Dispatcher\ObjectResult\ObjectSuccess )
1041
+            $route instanceof \Comodojo\Dispatcher\ObjectResult\ObjectSuccess)
1042 1042
         {
1043 1043
 
1044 1044
             $this->cacher->set($this->service_url, $route);
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 
1049 1049
         $this->header->free();
1050 1050
 
1051
-        if ( $cache == "CLIENT" OR $cache == "BOTH" ) $this->header->setClientCache($this->serviceroute->getTtl());
1051
+        if ($cache == "CLIENT" OR $cache == "BOTH") $this->header->setClientCache($this->serviceroute->getTtl());
1052 1052
 
1053 1053
         $this->header->setContentType($route->getContentType(), $route->getCharset());
1054 1054
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 
1071 1071
     private static function end($result) {
1072 1072
 
1073
-        if ( defined('DISPATCHER_PHPUNIT_TEST') && @constant('DISPATCHER_PHPUNIT_TEST') === true ) {
1073
+        if (defined('DISPATCHER_PHPUNIT_TEST') && @constant('DISPATCHER_PHPUNIT_TEST') === true) {
1074 1074
 
1075 1075
             return $result;
1076 1076
 
Please login to merge, or discard this patch.
src/Serialization.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return  string  JSON encoded data
39 39
      */
40
-    final public function toJson($data, $flags=null) {
40
+    final public function toJson($data, $flags = null) {
41 41
 
42
-        if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for JSON serialization");
42
+        if (!(is_array($data) OR is_object($data))) throw new Exception("Invalid data for JSON serialization");
43 43
 
44 44
         return json_encode($data, $flags);
45 45
 
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return  string  XML encoded data
57 57
      */
58
-    final public function toXml($data, $prettify=false) {
58
+    final public function toXml($data, $prettify = false) {
59 59
 
60
-        if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for XML serialization");
60
+        if (!(is_array($data) OR is_object($data))) throw new Exception("Invalid data for XML serialization");
61 61
 
62
-        if ( is_object($data) ) $data = $this->objectToArray($data);
62
+        if (is_object($data)) $data = $this->objectToArray($data);
63 63
 
64 64
         $xmlEngine = new XML();
65 65
         
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
      */
104 104
     final public function toYaml($data) {
105 105
 
106
-        if ( !( is_array($data) OR is_object($data) ) ) throw new Exception("Invalid data for XML serialization");
106
+        if (!(is_array($data) OR is_object($data))) throw new Exception("Invalid data for XML serialization");
107 107
 
108
-        if ( is_object($data) ) $data = $this->objectToArray($data);
108
+        if (is_object($data)) $data = $this->objectToArray($data);
109 109
 
110 110
         return \Spyc::YAMLDump($data);
111 111
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
        
148 148
         $indent = '';
149 149
 
150
-        $xmlString = str_replace("\n","",$xmlString);
150
+        $xmlString = str_replace("\n", "", $xmlString);
151 151
         $xmlString = trim(preg_replace("/<\?[^>]+>/", "", $xmlString));
152 152
         $xmlString = preg_replace("/>([\s]+)<\//", "></", $xmlString);
153 153
         $xmlString = str_replace(">", ">\n", $xmlString);
@@ -156,23 +156,23 @@  discard block
 block discarded – undo
156 156
 
157 157
         $_xmlString = '';
158 158
         
159
-        foreach($xmlStringArray as $k=>$tag){
159
+        foreach ($xmlStringArray as $k=>$tag) {
160 160
 
161 161
             if ($tag == "") continue;
162 162
             
163
-            if ($tag[0]=="<" AND $tag[1] != "/") {
163
+            if ($tag[0] == "<" AND $tag[1] != "/") {
164 164
 
165 165
                 $_xmlString .= $indent.$tag."\n";
166 166
                 $indent .= '  ';
167 167
 
168
-            } elseif($tag[0]=="<" AND $tag[1] == "/") {
168
+            } elseif ($tag[0] == "<" AND $tag[1] == "/") {
169 169
 
170
-                $indent = substr($indent,0,strlen($indent)-2);
171
-                $_xmlString .= (substr($_xmlString,strlen($_xmlString)-1)==">" || substr($_xmlString,strlen($_xmlString)-1)=="\n" ? $indent : '').$tag."\n";
170
+                $indent = substr($indent, 0, strlen($indent)-2);
171
+                $_xmlString .= (substr($_xmlString, strlen($_xmlString)-1) == ">" || substr($_xmlString, strlen($_xmlString)-1) == "\n" ? $indent : '').$tag."\n";
172 172
 
173 173
             } else {
174 174
 
175
-                $_xmlString = substr($_xmlString,0,strlen($_xmlString)-1);
175
+                $_xmlString = substr($_xmlString, 0, strlen($_xmlString)-1);
176 176
                 $_xmlString .= $tag;
177 177
 
178 178
             }
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
      */
192 192
     private function objectToArray($stdObj) {
193 193
        
194
-        if(is_object($stdObj)) {
194
+        if (is_object($stdObj)) {
195 195
 
196 196
             $array = array();
197 197
             
198
-            foreach($stdObj as $key=>$val){
198
+            foreach ($stdObj as $key=>$val) {
199 199
 
200 200
                 $array[$key] = objectToArray($val);
201 201
 
Please login to merge, or discard this patch.
src/Cache.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
             }
106 106
         }
107 107
         
108
-        $cacheTag = md5($request) . ".cache";
108
+        $cacheTag = md5($request).".cache";
109 109
 
110
-        $cacheFile = $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cacheTag;
110
+        $cacheFile = $this->cache_path.($this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/").$cacheTag;
111 111
 
112 112
         $f_data = serialize($data);
113 113
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * 
139 139
      * @return  array   An array containing maxage, bestbefore, object (data)
140 140
      */
141
-    final public function get($request, $ttl=DISPATCHER_CACHE_TTL) {
141
+    final public function get($request, $ttl = DISPATCHER_CACHE_TTL) {
142 142
         
143 143
         if (!DISPATCHER_CACHE_ENABLED) {
144 144
 
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 
149 149
         }
150 150
         
151
-        $last_time_limit = (int)$this->current_time - $ttl;
151
+        $last_time_limit = (int)$this->current_time-$ttl;
152 152
         
153
-        $cacheTag = md5($request) . ".cache";
153
+        $cacheTag = md5($request).".cache";
154 154
 
155
-        $cacheFile = $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cacheTag;
155
+        $cacheFile = $this->cache_path.($this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/").$cacheTag;
156 156
         
157 157
         $cache_time = @filemtime($cacheFile);
158 158
 
159 159
         if (is_readable($cacheFile) AND $cache_time >= $last_time_limit) {
160 160
             
161
-            $max_age = $cache_time + $ttl - (int)$this->current_time;
161
+            $max_age = $cache_time+$ttl-(int)$this->current_time;
162 162
 
163
-            $best_before = gmdate("D, d M Y H:i:s", $cache_time + $ttl) . " GMT";
163
+            $best_before = gmdate("D, d M Y H:i:s", $cache_time+$ttl)." GMT";
164 164
             
165 165
             $data = file_get_contents($cacheFile);
166 166
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
      *
205 205
      * @return  bool
206 206
      */
207
-    public function purge($request=null) {
207
+    public function purge($request = null) {
208 208
 
209
-        if ( is_null($request) ) {
209
+        if (is_null($request)) {
210 210
 
211 211
             $this->logger->info('Purging whole cache');
212 212
 
213 213
             $cache_files_number = 0;
214 214
 
215 215
             $cache_path = opendir($this->cache_path);
216
-            if ( $cache_path === false ) {
216
+            if ($cache_path === false) {
217 217
 
218 218
                 $this->logger->error('Unable to open cache folder', array(
219 219
                     'CACHEFOLDER' => $this->cache_path
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
 
224 224
             }
225 225
             
226
-            while( false !== ( $cache_file = readdir($cache_path) ) ) {
226
+            while (false !== ($cache_file = readdir($cache_path))) {
227 227
 
228
-                if ( pathinfo($cache_file, PATHINFO_EXTENSION) == "cache" ) {
229
-                    if ( unlink( $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cache_file ) == false ) return false;
228
+                if (pathinfo($cache_file, PATHINFO_EXTENSION) == "cache") {
229
+                    if (unlink($this->cache_path.($this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/").$cache_file) == false) return false;
230 230
                     else $cache_files_number++;
231 231
                 }
232 232
                 else continue;
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
                 'REQUEST' => $request
243 243
             ));
244 244
 
245
-            $cacheTag = md5($request) . ".cache";
245
+            $cacheTag = md5($request).".cache";
246 246
 
247
-            $cacheFile = $this->cache_path . ( $this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/" ) . $cacheTag;
247
+            $cacheFile = $this->cache_path.($this->cache_path[strlen($this->cache_path)-1] == "/" ? "" : "/").$cacheTag;
248 248
 
249
-            if ( is_readable($cacheFile) ) {
249
+            if (is_readable($cacheFile)) {
250 250
 
251 251
                 $unlink = unlink($cacheFile);
252 252
                 $cache_files_number = $unlink ? 1 : false;
Please login to merge, or discard this patch.
src/ObjectRoutingTable/ObjectRoutingTable.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var array
50 50
      */
51
-    private $supported_route_types = array("ROUTE","REDIRECT","ERROR");
51
+    private $supported_route_types = array("ROUTE", "REDIRECT", "ERROR");
52 52
 
53 53
     /**
54 54
      * Object constructor.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      *
78 78
      * @return  Object  $this
79 79
      */
80
-    public function setRoute($service, $type, $target, $parameters=array()) {
80
+    public function setRoute($service, $type, $target, $parameters = array()) {
81 81
 
82 82
         $this->table[$service] = array(
83 83
             "type"          =>  $type,
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function unsetRoute($service) {
100 100
 
101
-        if ( isset($this->table[$service]) ) {
101
+        if (isset($this->table[$service])) {
102 102
 
103 103
             unset($this->table[$service]);
104 104
 
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
 
122 122
         // If service is null, route to landing or (if not specified) to default route
123 123
 
124
-        if ( empty($service) ) return $this->routeToLanding();
124
+        if (empty($service)) return $this->routeToLanding();
125 125
 
126 126
         // If service is in table, check if it is routable (in case of "ROUTE" route).
127 127
         // If true, route request
128 128
         // If false, return a 500 error
129 129
 
130
-        if ( isset($this->table[$service]) ) {
130
+        if (isset($this->table[$service])) {
131 131
 
132
-            if ( $this->table[$service]["type"] == "ROUTE" ) {
132
+            if ($this->table[$service]["type"] == "ROUTE") {
133 133
 
134
-                if ( $this->routable($this->table[$service]["target"]) ) return $this->table[$service];
134
+                if ($this->routable($this->table[$service]["target"])) return $this->table[$service];
135 135
 
136 136
                 else return $this->routeToNowhere();
137 137
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         // If autoroute is enabled, try to match service name with a service file.
145 145
         // If true, try to route request
146 146
 
147
-        else if ( defined('DISPATCHER_AUTO_ROUTE') && DISPATCHER_AUTO_ROUTE === true AND $this->routable($service.".php", true) ) {
147
+        else if (defined('DISPATCHER_AUTO_ROUTE') && DISPATCHER_AUTO_ROUTE === true AND $this->routable($service.".php", true)) {
148 148
 
149 149
             return array(
150 150
                 "type"          =>  "ROUTE",
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
      *
179 179
      * @return  bool
180 180
      */
181
-    private function routable($target, $relative=false) {
181
+    private function routable($target, $relative = false) {
182 182
 
183
-        if ( $relative ) return is_readable(DISPATCHER_SERVICES_FOLDER.$target) ? true : false;
183
+        if ($relative) return is_readable(DISPATCHER_SERVICES_FOLDER.$target) ? true : false;
184 184
 
185 185
         else return is_readable($target) ? true : false;
186 186
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     private function routeToLanding() {
195 195
 
196
-        if ( isset($this->table[""]) ) {
196
+        if (isset($this->table[""])) {
197 197
 
198 198
             return $this->table[""];
199 199
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      */
211 211
     private function routeToDefault() {
212 212
 
213
-        if ( isset($this->table["default"]) ) {
213
+        if (isset($this->table["default"])) {
214 214
 
215 215
             return $this->table["default"];
216 216
 
Please login to merge, or discard this patch.
src/ObjectRequest/ObjectRequest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
      *
164 164
      * @return  Object  $this
165 165
      */
166
-    public function setAttribute($name=null, $value) {
166
+    public function setAttribute($name = null, $value) {
167 167
 
168
-        if ( is_null($name) ) array_push($this->attributes, $value);
168
+        if (is_null($name)) array_push($this->attributes, $value);
169 169
 
170 170
         else $this->attributes[$name] = $value;
171 171
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function unsetAttribute($attribute) {
184 184
 
185
-        if ( array_key_exists($attribute, $this->attributes) ) {
185
+        if (array_key_exists($attribute, $this->attributes)) {
186 186
 
187 187
             unset($this->attributes[$attribute]);
188 188
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function getAttribute($attribute) {
205 205
 
206
-        if ( array_key_exists($attribute, $this->attributes) ) {
206
+        if (array_key_exists($attribute, $this->attributes)) {
207 207
 
208 208
             return $this->attributes[$attribute];
209 209
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      */
278 278
     public function unsetParameter($parameter) {
279 279
 
280
-        if ( array_key_exists($parameter, $this->parameters) ) {
280
+        if (array_key_exists($parameter, $this->parameters)) {
281 281
 
282 282
             unset($this->parameters[$parameter]);
283 283
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function getParameter($parameter) {
300 300
 
301
-        if ( array_key_exists($parameter, $this->parameters) ) {
301
+        if (array_key_exists($parameter, $this->parameters)) {
302 302
 
303 303
             return $this->parameters[$parameter];
304 304
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
      *
380 380
      * @return  ObjectRequest   $this
381 381
      */
382
-    public function setHeader($header, $value=null) {
382
+    public function setHeader($header, $value = null) {
383 383
 
384 384
         $this->headers[$header] = $value;
385 385
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function unsetHeader($header) {
398 398
 
399
-        if ( isset($this->headers[$header]) ) {
399
+        if (isset($this->headers[$header])) {
400 400
 
401 401
             unset($this->headers[$header]);
402 402
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
      */
418 418
     public function getHeader($header) {
419 419
 
420
-        if ( isset($this->headers[$header]) ) return $this->headers[$header];
420
+        if (isset($this->headers[$header])) return $this->headers[$header];
421 421
 
422 422
         return null;
423 423
 
Please login to merge, or discard this patch.
src/Header.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @param   string  $time   Dispatcher time
49 49
      */
50
-    final public function __construct($time=false) {
50
+    final public function __construct($time = false) {
51 51
 
52 52
         $this->current_time = $time !== false ? $time : microtime(true);
53 53
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * @param   mixed   $value    Header value (if not included in $header)
61 61
      * @return  Object  $this
62 62
      */
63
-    final public function set($header, $value=null) {
63
+    final public function set($header, $value = null) {
64 64
 
65 65
         $this->headers[$header] = $value;
66 66
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     final public function get($header) {
79 79
 
80
-        if ( array_key_exists($header, $this->headers) ) return $this->headers[$header];
80
+        if (array_key_exists($header, $this->headers)) return $this->headers[$header];
81 81
 
82 82
         else return null;
83 83
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      * @param   integer     $contentLength  Content length
114 114
      * @param   string      $value          (optional) value (see method description)
115 115
      */
116
-    final public function compose($status, $contentLength=0, $value=false) {
116
+    final public function compose($status, $contentLength = 0, $value = false) {
117 117
 
118 118
         switch ($status) {
119 119
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
             header($_SERVER["SERVER_PROTOCOL"].' 204 No Content');
147 147
             header('Status: 204 No Content');
148
-            header('Content-Length: 0',true);
148
+            header('Content-Length: 0', true);
149 149
 
150 150
             $this->processExtraHeaders($this->headers);
151 151
             
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
             case 303: //See Other
158 158
             case 307: //Temporary Redirect
159 159
 
160
-            header("Location: ".$value,true,$status);
160
+            header("Location: ".$value, true, $status);
161 161
             
162 162
             break;
163 163
 
164 164
             case 304: //Not Modified
165 165
 
166
-            if ( $value === false ) header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified');
166
+            if ($value === false) header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified');
167 167
             else header('Last-Modified: '.gmdate('D, d M Y H:i:s', $value).' GMT', true, 304);
168 168
 
169 169
                 if ($contentLength !== 0) header('Content-Length: '.$contentLength); //is it needed?
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
             case 405: //Not allowed
199 199
 
200
-            header('Allow: ' . $value, true, 405); 
200
+            header('Allow: '.$value, true, 405); 
201 201
 
202 202
             break;
203 203
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
             case 501: //Not implemented
211 211
 
212
-            header('Allow: ' . $value, true, 501);
212
+            header('Allow: '.$value, true, 501);
213 213
             
214 214
             break;
215 215
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
             header('HTTP/1.1 503 Service Temporarily Unavailable');
219 219
             header('Status: 503 Service Temporarily Unavailable');
220
-            if ( $value !== false AND @is_int($value) ) {
220
+            if ($value !== false AND @is_int($value)) {
221 221
                 header('Retry-After: '.$value);
222 222
             }
223 223
             
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 
238 238
         $ttl = filter_var($ttl, FILTER_VALIDATE_INT);
239 239
 
240
-        if ( $ttl > 0 ) {
241
-            $this->set("Cache-Control","max-age=".$ttl.", must-revalidate");
242
-            $this->set("Expires",gmdate("D, d M Y H:i:s", (int)$this->current_time + $ttl)." GMT");
240
+        if ($ttl > 0) {
241
+            $this->set("Cache-Control", "max-age=".$ttl.", must-revalidate");
242
+            $this->set("Expires", gmdate("D, d M Y H:i:s", (int)$this->current_time+$ttl)." GMT");
243 243
         }
244 244
         else {
245
-            $this->set("Cache-Control","no-cache, must-revalidate");
246
-            $this->set("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
245
+            $this->set("Cache-Control", "no-cache, must-revalidate");
246
+            $this->set("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
247 247
         }
248 248
 
249 249
         return $this;
@@ -257,11 +257,11 @@  discard block
 block discarded – undo
257 257
      * @param   string      $charset    Charset
258 258
      * @return  Object      $this
259 259
      */
260
-    public function setContentType($type, $charset=null) {
260
+    public function setContentType($type, $charset = null) {
261 261
 
262 262
 
263
-        if ( is_null($charset) ) $this->set("Content-type",strtolower($type));
264
-        else $this->set("Content-type",strtolower($type)."; charset=".$charset);
263
+        if (is_null($charset)) $this->set("Content-type", strtolower($type));
264
+        else $this->set("Content-type", strtolower($type)."; charset=".$charset);
265 265
 
266 266
         return $this;
267 267
 
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
      */
299 299
     private function processExtraHeaders($headers) {
300 300
 
301
-        foreach ( $headers as $header => $value ) {
301
+        foreach ($headers as $header => $value) {
302 302
 
303
-            if ( is_null($value) ) header($header, true);
303
+            if (is_null($value)) header($header, true);
304 304
             else  header($header.": ".$value, true);
305 305
 
306 306
         }
Please login to merge, or discard this patch.
src/ObjectResult/ObjectRedirect.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 
30 30
     private $code = 307;
31 31
 
32
-    private $supported_redirect_codes = array(201,301,302,303,307);
32
+    private $supported_redirect_codes = array(201, 301, 302, 303, 307);
33 33
 
34 34
     private $location = null;
35 35
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      *
136 136
      * @return  ObjectRequest   $this
137 137
      */
138
-    public function setHeader($header, $value=null) {
138
+    public function setHeader($header, $value = null) {
139 139
 
140 140
         $this->headers[$header] = $value;
141 141
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function unsetHeader($header) {
154 154
 
155
-        if ( isset($this->headers[$header]) ) {
155
+        if (isset($this->headers[$header])) {
156 156
 
157 157
             unset($this->headers[$header]);
158 158
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public function getHeader($header) {
175 175
 
176
-        if ( isset($this->headers[$header]) ) return $this->headers[$header];
176
+        if (isset($this->headers[$header])) return $this->headers[$header];
177 177
 
178 178
         return null;
179 179
 
Please login to merge, or discard this patch.
src/ObjectResult/ObjectSuccess.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
     private $charset = DISPATCHER_DEFAULT_ENCODING;
39 39
 
40
-    private $supported_success_codes = array(200,202,204);
40
+    private $supported_success_codes = array(200, 202, 204);
41 41
 
42 42
     /**
43 43
      * Set service name
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      *
138 138
      * @return  ObjectRequest   $this
139 139
      */
140
-    public function setHeader($header, $value=null) {
140
+    public function setHeader($header, $value = null) {
141 141
 
142 142
         $this->headers[$header] = $value;
143 143
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function unsetHeader($header) {
156 156
 
157
-        if ( isset($this->headers[$header]) ) {
157
+        if (isset($this->headers[$header])) {
158 158
 
159 159
             unset($this->headers[$header]);
160 160
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public function getHeader($header) {
177 177
 
178
-        if ( isset($this->headers[$header]) ) return $this->headers[$header];
178
+        if (isset($this->headers[$header])) return $this->headers[$header];
179 179
 
180 180
         return null;
181 181
 
Please login to merge, or discard this patch.