Completed
Push — master ( 09e053...ddf9dd )
by Filippo
01:43
created
src/EoC/Message/Response.php 1 patch
Braces   +31 added lines, -24 removed lines patch added patch discarded remove patch
@@ -423,13 +423,15 @@  discard block
 block discarded – undo
423 423
    */
424 424
   protected function parseStatusCode($rawMessage) {
425 425
     $matches = [];
426
-    if (preg_match('%HTTP/1\.[0-1] (\d\d\d) %', $rawMessage, $matches))
427
-      $this->statusCode = $matches[1];
428
-    else
429
-      throw new \UnexpectedValueException("HTTP Status Code undefined.");
426
+    if (preg_match('%HTTP/1\.[0-1] (\d\d\d) %', $rawMessage, $matches)) {
427
+          $this->statusCode = $matches[1];
428
+    } else {
429
+          throw new \UnexpectedValueException("HTTP Status Code undefined.");
430
+    }
430 431
 
431
-    if (!array_key_exists($this->statusCode, self::$supportedStatusCodes))
432
-      throw new \UnexpectedValueException("HTTP Status Code unknown.");
432
+    if (!array_key_exists($this->statusCode, self::$supportedStatusCodes)) {
433
+          throw new \UnexpectedValueException("HTTP Status Code unknown.");
434
+    }
433 435
   }
434 436
 
435 437
 
@@ -449,10 +451,11 @@  discard block
 block discarded – undo
449 451
             },
450 452
             strtolower(trim($matches[1])));
451 453
 
452
-        if (isset($this->header[$matches[1]]))
453
-          $this->header[$matches[1]] = array($this->header[$matches[1]], $matches[2]);
454
-        else
455
-          $this->header[$matches[1]] = trim($matches[2]);
454
+        if (isset($this->header[$matches[1]])) {
455
+                  $this->header[$matches[1]] = array($this->header[$matches[1]], $matches[2]);
456
+        } else {
457
+                  $this->header[$matches[1]] = trim($matches[2]);
458
+        }
456 459
       }
457 460
     }
458 461
   }
@@ -463,11 +466,13 @@  discard block
 block discarded – undo
463 466
    * @param[in] string $rawMessage The raw message.
464 467
    */
465 468
   protected function parseStatusCodeAndHeader($rawMessage) {
466
-    if (!is_string($rawMessage))
467
-      throw new \InvalidArgumentException("\$rawMessage must be a string.");
469
+    if (!is_string($rawMessage)) {
470
+          throw new \InvalidArgumentException("\$rawMessage must be a string.");
471
+    }
468 472
 
469
-    if (empty($rawMessage))
470
-      throw new \UnexpectedValueException("\$rawMessage is null.");
473
+    if (empty($rawMessage)) {
474
+          throw new \UnexpectedValueException("\$rawMessage is null.");
475
+    }
471 476
 
472 477
     $this->parseStatusCode($rawMessage);
473 478
 
@@ -481,8 +486,9 @@  discard block
 block discarded – undo
481 486
 
482 487
     $rawMessage = preg_split('/\r\n\r\n/', $rawMessage, 2);
483 488
 
484
-    if (empty($rawMessage))
485
-      throw new \RuntimeException("The server didn't return a valid Response for the Request.");
489
+    if (empty($rawMessage)) {
490
+          throw new \RuntimeException("The server didn't return a valid Response for the Request.");
491
+    }
486 492
 
487 493
     // $rawMessage[0] contains header fields.
488 494
     $this->parseHeaderFields($rawMessage[0]);
@@ -508,9 +514,9 @@  discard block
 block discarded – undo
508 514
   public function setStatusCode($value) {
509 515
     if (array_key_exists($value, self::$supportedStatusCodes)) {
510 516
       $this->statusCode = $value;
517
+    } else {
518
+          throw new \UnexpectedValueException("Status Code $value is not supported.");
511 519
     }
512
-    else
513
-      throw new \UnexpectedValueException("Status Code $value is not supported.");
514 520
   }
515 521
 
516 522
 
@@ -529,12 +535,13 @@  discard block
 block discarded – undo
529 535
    * @param[in] string $description A description for the Status Code.
530 536
    */
531 537
   public static function addCustomStatusCode($code, $description) {
532
-    if (in_array($code, self::$supportedStatusCodes))
533
-      throw new \UnexpectedValueException("Status Code $code is supported and already exists.");
534
-    elseif (is_int($code) and $code > 0)
535
-      self::$supportedStatusCodes[$code] = $description;
536
-    else
537
-      throw new \InvalidArgumentException("\$code must be a positive integer.");
538
+    if (in_array($code, self::$supportedStatusCodes)) {
539
+          throw new \UnexpectedValueException("Status Code $code is supported and already exists.");
540
+    } elseif (is_int($code) and $code > 0) {
541
+          self::$supportedStatusCodes[$code] = $description;
542
+    } else {
543
+          throw new \InvalidArgumentException("\$code must be a positive integer.");
544
+    }
538 545
   }
539 546
 
540 547
 }
541 548
\ No newline at end of file
Please login to merge, or discard this patch.
src/EoC/Doc/AbstractDoc.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -149,8 +149,9 @@  discard block
 block discarded – undo
149 149
 
150 150
 
151 151
   public function unsetId() {
152
-    if ($this->isMetadataPresent('_id'))
153
-      unset($this->meta['_id']);
152
+    if ($this->isMetadataPresent('_id')) {
153
+          unset($this->meta['_id']);
154
+    }
154 155
   }
155 156
 
156 157
 
@@ -170,8 +171,9 @@  discard block
 block discarded – undo
170 171
 
171 172
 
172 173
   public function unsetRev() {
173
-    if ($this->isMetadataPresent('_rev'))
174
-      unset($this->meta['_rev']);
174
+    if ($this->isMetadataPresent('_rev')) {
175
+          unset($this->meta['_rev']);
176
+    }
175 177
   }
176 178
 
177 179
   //! @endcond
Please login to merge, or discard this patch.