@@ -54,8 +54,9 @@ discard block |
||
| 54 | 54 | public function getAttachments() { |
| 55 | 55 | $attachments = []; |
| 56 | 56 | |
| 57 | - foreach ($this->meta[self::ATTACHMENTS] as $attachment) |
|
| 58 | - $attachments[] = Attachment::fromArray($attachment); |
|
| 57 | + foreach ($this->meta[self::ATTACHMENTS] as $attachment) { |
|
| 58 | + $attachments[] = Attachment::fromArray($attachment); |
|
| 59 | + } |
|
| 59 | 60 | |
| 60 | 61 | return $attachments; |
| 61 | 62 | } |
@@ -75,13 +76,15 @@ discard block |
||
| 75 | 76 | * @todo To be documented. |
| 76 | 77 | */ |
| 77 | 78 | public function removeAttachment($name) { |
| 78 | - if ($this->isMetadataPresent(self::ATTACHMENTS)) |
|
| 79 | - if (array_key_exists($name, $this->meta[self::ATTACHMENTS])) |
|
| 79 | + if ($this->isMetadataPresent(self::ATTACHMENTS)) { |
|
| 80 | + if (array_key_exists($name, $this->meta[self::ATTACHMENTS])) |
|
| 80 | 81 | unset($this->meta[self::ATTACHMENTS][$name]); |
| 81 | - else |
|
| 82 | - throw new \Exception("Can't find `$name` attachment in the document."); |
|
| 83 | - else |
|
| 84 | - throw new \Exception("The document doesn't have any attachment."); |
|
| 82 | + } else { |
|
| 83 | + throw new \Exception("Can't find `$name` attachment in the document."); |
|
| 84 | + } |
|
| 85 | + else { |
|
| 86 | + throw new \Exception("The document doesn't have any attachment."); |
|
| 87 | + } |
|
| 85 | 88 | } |
| 86 | 89 | |
| 87 | 90 | |
@@ -48,19 +48,22 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) { |
| 51 | - if (is_null($value) && !$allowNull) |
|
| 52 | - return; |
|
| 51 | + if (is_null($value) && !$allowNull) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 53 | 54 | |
| 54 | - if ($this->isMetadataPresent($name) && !$override) |
|
| 55 | - return; |
|
| 55 | + if ($this->isMetadataPresent($name) && !$override) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 56 | 58 | |
| 57 | 59 | $this->meta[$name] = $value; |
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | |
| 61 | 63 | public function unsetMetadata($name) { |
| 62 | - if (array_key_exists($name, $this->meta)) |
|
| 63 | - unset($this->meta[$name]); |
|
| 64 | + if (array_key_exists($name, $this->meta)) { |
|
| 65 | + unset($this->meta[$name]); |
|
| 66 | + } |
|
| 64 | 67 | } |
| 65 | 68 | |
| 66 | 69 | |
@@ -94,9 +97,9 @@ discard block |
||
| 94 | 97 | if (Helper\ArrayHelper::isAssociative($array)) { |
| 95 | 98 | $this->meta = array_merge($this->meta, $array); |
| 96 | 99 | $this->fixDocId(); |
| 100 | + } else { |
|
| 101 | + throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 97 | 102 | } |
| 98 | - else |
|
| 99 | - throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 100 | 103 | } |
| 101 | 104 | |
| 102 | 105 | |
@@ -147,8 +150,9 @@ discard block |
||
| 147 | 150 | |
| 148 | 151 | |
| 149 | 152 | public function unsetId() { |
| 150 | - if ($this->isMetadataPresent('_id')) |
|
| 151 | - unset($this->meta['_id']); |
|
| 153 | + if ($this->isMetadataPresent('_id')) { |
|
| 154 | + unset($this->meta['_id']); |
|
| 155 | + } |
|
| 152 | 156 | } |
| 153 | 157 | |
| 154 | 158 | |
@@ -168,8 +172,9 @@ discard block |
||
| 168 | 172 | |
| 169 | 173 | |
| 170 | 174 | public function unsetRev() { |
| 171 | - if ($this->isMetadataPresent('_rev')) |
|
| 172 | - unset($this->meta['_rev']); |
|
| 175 | + if ($this->isMetadataPresent('_rev')) { |
|
| 176 | + unset($this->meta['_rev']); |
|
| 177 | + } |
|
| 173 | 178 | } |
| 174 | 179 | |
| 175 | 180 | } |
| 176 | 181 | \ No newline at end of file |
@@ -81,10 +81,11 @@ discard block |
||
| 81 | 81 | * @param[in] integer $since Sequence number to start results. Allowed values: positive integers | 'now'. |
| 82 | 82 | */ |
| 83 | 83 | public function setSince($since = 0) { |
| 84 | - if (($since == "now") or (is_int($since) and ($since >= 0))) |
|
| 85 | - $this->options["since"] = $since; |
|
| 86 | - else |
|
| 87 | - throw new \InvalidArgumentException("\$since must be a non-negative integer or can be 'now'."); |
|
| 84 | + if (($since == "now") or (is_int($since) and ($since >= 0))) { |
|
| 85 | + $this->options["since"] = $since; |
|
| 86 | + } else { |
|
| 87 | + throw new \InvalidArgumentException("\$since must be a non-negative integer or can be 'now'."); |
|
| 88 | + } |
|
| 88 | 89 | |
| 89 | 90 | return $this; |
| 90 | 91 | } |
@@ -95,10 +96,11 @@ discard block |
||
| 95 | 96 | * @param[in] integer $limit Maximum number of rows to return. Must be a positive integer. |
| 96 | 97 | */ |
| 97 | 98 | public function setLimit($limit) { |
| 98 | - if (is_int($limit) and ($limit > 0)) |
|
| 99 | - $this->options["limit"] = $limit; |
|
| 100 | - else |
|
| 101 | - throw new \InvalidArgumentException("\$value must be a positive integer."); |
|
| 99 | + if (is_int($limit) and ($limit > 0)) { |
|
| 100 | + $this->options["limit"] = $limit; |
|
| 101 | + } else { |
|
| 102 | + throw new \InvalidArgumentException("\$value must be a positive integer."); |
|
| 103 | + } |
|
| 102 | 104 | |
| 103 | 105 | return $this; |
| 104 | 106 | } |
@@ -117,10 +119,11 @@ discard block |
||
| 117 | 119 | * @param[in] string $type Type of feed. |
| 118 | 120 | */ |
| 119 | 121 | public function setFeedType($type) { |
| 120 | - if (array_key_exists($type, self::$supportedTypes)) |
|
| 121 | - $this->options["feed"] = $type; |
|
| 122 | - else |
|
| 123 | - throw new \InvalidArgumentException("Invalid feed type."); |
|
| 122 | + if (array_key_exists($type, self::$supportedTypes)) { |
|
| 123 | + $this->options["feed"] = $type; |
|
| 124 | + } else { |
|
| 125 | + throw new \InvalidArgumentException("Invalid feed type."); |
|
| 126 | + } |
|
| 124 | 127 | } |
| 125 | 128 | |
| 126 | 129 | |
@@ -130,10 +133,11 @@ discard block |
||
| 130 | 133 | * @param[in] bool $style The feed style. |
| 131 | 134 | */ |
| 132 | 135 | public function setStyle($style) { |
| 133 | - if (array_key_exists($style, self::$supportedStyles)) |
|
| 134 | - $this->options["style"] = $style; |
|
| 135 | - else |
|
| 136 | - throw new \InvalidArgumentException("Invalid feed style."); |
|
| 136 | + if (array_key_exists($style, self::$supportedStyles)) { |
|
| 137 | + $this->options["style"] = $style; |
|
| 138 | + } else { |
|
| 139 | + throw new \InvalidArgumentException("Invalid feed style."); |
|
| 140 | + } |
|
| 137 | 141 | } |
| 138 | 142 | |
| 139 | 143 | |
@@ -146,11 +150,12 @@ discard block |
||
| 146 | 150 | public function setHeartbeat($heartbeat = self::DEFAULT_HEARTBEAT) { |
| 147 | 151 | $feed = $this->options['feed']; |
| 148 | 152 | |
| 149 | - if (($feed == self::CONTINUOUS_TYPE) or ($feed == self::LONGPOLL_TYPE)) |
|
| 150 | - if (is_int($heartbeat) and ($heartbeat >= 0)) |
|
| 153 | + if (($feed == self::CONTINUOUS_TYPE) or ($feed == self::LONGPOLL_TYPE)) { |
|
| 154 | + if (is_int($heartbeat) and ($heartbeat >= 0)) |
|
| 151 | 155 | $this->options["heartbeat"] = $heartbeat; |
| 152 | - else |
|
| 153 | - throw new \InvalidArgumentException("\$heartbeat must be a non-negative integer."); |
|
| 156 | + } else { |
|
| 157 | + throw new \InvalidArgumentException("\$heartbeat must be a non-negative integer."); |
|
| 158 | + } |
|
| 154 | 159 | } |
| 155 | 160 | |
| 156 | 161 | |
@@ -163,11 +168,12 @@ discard block |
||
| 163 | 168 | public function setTimeout($timeout = self::DEFAULT_TIMEOUT) { |
| 164 | 169 | $feed = $this->options['feed']; |
| 165 | 170 | |
| 166 | - if (($feed == self::CONTINUOUS_TYPE) or ($feed == self::LONGPOLL_TYPE)) |
|
| 167 | - if (is_int($timeout) and ($timeout > 0)) |
|
| 171 | + if (($feed == self::CONTINUOUS_TYPE) or ($feed == self::LONGPOLL_TYPE)) { |
|
| 172 | + if (is_int($timeout) and ($timeout > 0)) |
|
| 168 | 173 | $this->options["timeout"] = $timeout; |
| 169 | - else |
|
| 170 | - throw new \InvalidArgumentException("\$timeout must be a positive integer."); |
|
| 174 | + } else { |
|
| 175 | + throw new \InvalidArgumentException("\$timeout must be a positive integer."); |
|
| 176 | + } |
|
| 171 | 177 | } |
| 172 | 178 | |
| 173 | 179 | |
@@ -63,10 +63,11 @@ discard block |
||
| 63 | 63 | * @param[in] string $type Type of feed. |
| 64 | 64 | */ |
| 65 | 65 | public function setFeedType($type) { |
| 66 | - if (array_key_exists($type, self::$supportedTypes)) |
|
| 67 | - $this->options["feed"] = $type; |
|
| 68 | - else |
|
| 69 | - throw new \InvalidArgumentException("Invalid feed type."); |
|
| 66 | + if (array_key_exists($type, self::$supportedTypes)) { |
|
| 67 | + $this->options["feed"] = $type; |
|
| 68 | + } else { |
|
| 69 | + throw new \InvalidArgumentException("Invalid feed type."); |
|
| 70 | + } |
|
| 70 | 71 | |
| 71 | 72 | return $this; |
| 72 | 73 | } |
@@ -81,11 +82,12 @@ discard block |
||
| 81 | 82 | public function setTimeout($timeout = self::DEFAULT_TIMEOUT) { |
| 82 | 83 | $feed = $this->options['feed']; |
| 83 | 84 | |
| 84 | - if ($feed == self::CONTINUOUS_TYPE) |
|
| 85 | - if (is_int($timeout) and ($timeout > 0)) |
|
| 85 | + if ($feed == self::CONTINUOUS_TYPE) { |
|
| 86 | + if (is_int($timeout) and ($timeout > 0)) |
|
| 86 | 87 | $this->options["timeout"] = $timeout; |
| 87 | - else |
|
| 88 | - throw new \InvalidArgumentException("\$timeout must be a positive integer."); |
|
| 88 | + } else { |
|
| 89 | + throw new \InvalidArgumentException("\$timeout must be a positive integer."); |
|
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | return $this; |
| 91 | 93 | } |
@@ -36,8 +36,9 @@ discard block |
||
| 36 | 36 | * @attention Chainable. |
| 37 | 37 | */ |
| 38 | 38 | public function unsetOpt($name) { |
| 39 | - if (array_key_exists($name, $this->options)) |
|
| 40 | - unset($this->options['name']); |
|
| 39 | + if (array_key_exists($name, $this->options)) { |
|
| 40 | + unset($this->options['name']); |
|
| 41 | + } |
|
| 41 | 42 | |
| 42 | 43 | return $this; |
| 43 | 44 | } |
@@ -137,10 +138,11 @@ discard block |
||
| 137 | 138 | * @attention Chainable. |
| 138 | 139 | */ |
| 139 | 140 | public function setLimit($value) { |
| 140 | - if (is_int($value) && $value > 0) |
|
| 141 | - $this->options["limit"] = $value; |
|
| 142 | - else |
|
| 143 | - throw new \Exception("\$value must be a positive integer."); |
|
| 141 | + if (is_int($value) && $value > 0) { |
|
| 142 | + $this->options["limit"] = $value; |
|
| 143 | + } else { |
|
| 144 | + throw new \Exception("\$value must be a positive integer."); |
|
| 145 | + } |
|
| 144 | 146 | |
| 145 | 147 | return $this; |
| 146 | 148 | } |
@@ -173,9 +175,9 @@ discard block |
||
| 173 | 175 | if (is_int($value) && $value > 0) { |
| 174 | 176 | $this->options["group"] = "false"; // This parameter is used only if 'group' is 'false'. |
| 175 | 177 | $this->options["group_level"] = $value; |
| 178 | + } else { |
|
| 179 | + throw new \Exception("\$value must be a positive integer."); |
|
| 176 | 180 | } |
| 177 | - else |
|
| 178 | - throw new \Exception("\$value must be a positive integer."); |
|
| 179 | 181 | |
| 180 | 182 | return $this; |
| 181 | 183 | } |
@@ -310,10 +312,11 @@ discard block |
||
| 310 | 312 | * @attention Chainable. |
| 311 | 313 | */ |
| 312 | 314 | public function skipDocs($number) { |
| 313 | - if (is_int($number) && $number > 0) |
|
| 314 | - $this->options["skip"] = $number; |
|
| 315 | - else |
|
| 316 | - throw new \Exception("\$number must be a positive integer."); |
|
| 315 | + if (is_int($number) && $number > 0) { |
|
| 316 | + $this->options["skip"] = $number; |
|
| 317 | + } else { |
|
| 318 | + throw new \Exception("\$number must be a positive integer."); |
|
| 319 | + } |
|
| 317 | 320 | |
| 318 | 321 | return $this; |
| 319 | 322 | } |
@@ -143,10 +143,11 @@ |
||
| 143 | 143 | * @param[in] string|array $revs The revision(s) identifier(s). |
| 144 | 144 | */ |
| 145 | 145 | public function includeOpenRevs($revs = 'all') { |
| 146 | - if (is_array($revs)) |
|
| 147 | - $this->options['open_revs'] = json_encode($revs); |
|
| 148 | - else |
|
| 149 | - $this->options['open_revs'] = 'all'; |
|
| 146 | + if (is_array($revs)) { |
|
| 147 | + $this->options['open_revs'] = json_encode($revs); |
|
| 148 | + } else { |
|
| 149 | + $this->options['open_revs'] = 'all'; |
|
| 150 | + } |
|
| 150 | 151 | |
| 151 | 152 | return $this; |
| 152 | 153 | } |
@@ -417,13 +417,15 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | protected function parseStatusCode($rawMessage) { |
| 419 | 419 | $matches = []; |
| 420 | - if (preg_match('%HTTP/1\.[0-1] (\d\d\d) %', $rawMessage, $matches)) |
|
| 421 | - $this->statusCode = $matches[1]; |
|
| 422 | - else |
|
| 423 | - throw new \UnexpectedValueException("HTTP Status Code undefined."); |
|
| 420 | + if (preg_match('%HTTP/1\.[0-1] (\d\d\d) %', $rawMessage, $matches)) { |
|
| 421 | + $this->statusCode = $matches[1]; |
|
| 422 | + } else { |
|
| 423 | + throw new \UnexpectedValueException("HTTP Status Code undefined."); |
|
| 424 | + } |
|
| 424 | 425 | |
| 425 | - if (!array_key_exists($this->statusCode, self::$supportedStatusCodes)) |
|
| 426 | - throw new \UnexpectedValueException("HTTP Status Code unknown."); |
|
| 426 | + if (!array_key_exists($this->statusCode, self::$supportedStatusCodes)) { |
|
| 427 | + throw new \UnexpectedValueException("HTTP Status Code unknown."); |
|
| 428 | + } |
|
| 427 | 429 | } |
| 428 | 430 | |
| 429 | 431 | |
@@ -439,21 +441,24 @@ discard block |
||
| 439 | 441 | }, |
| 440 | 442 | strtolower(trim($matches[1]))); |
| 441 | 443 | |
| 442 | - if (isset($this->header[$matches[1]])) |
|
| 443 | - $this->header[$matches[1]] = array($this->header[$matches[1]], $matches[2]); |
|
| 444 | - else |
|
| 445 | - $this->header[$matches[1]] = trim($matches[2]); |
|
| 444 | + if (isset($this->header[$matches[1]])) { |
|
| 445 | + $this->header[$matches[1]] = array($this->header[$matches[1]], $matches[2]); |
|
| 446 | + } else { |
|
| 447 | + $this->header[$matches[1]] = trim($matches[2]); |
|
| 448 | + } |
|
| 446 | 449 | } |
| 447 | 450 | } |
| 448 | 451 | } |
| 449 | 452 | |
| 450 | 453 | |
| 451 | 454 | protected function parseStatusCodeAndHeader($rawMessage) { |
| 452 | - if (!is_string($rawMessage)) |
|
| 453 | - throw new \InvalidArgumentException("\$rawMessage must be a string."); |
|
| 455 | + if (!is_string($rawMessage)) { |
|
| 456 | + throw new \InvalidArgumentException("\$rawMessage must be a string."); |
|
| 457 | + } |
|
| 454 | 458 | |
| 455 | - if (empty($rawMessage)) |
|
| 456 | - throw new \UnexpectedValueException("\$rawMessage is null."); |
|
| 459 | + if (empty($rawMessage)) { |
|
| 460 | + throw new \UnexpectedValueException("\$rawMessage is null."); |
|
| 461 | + } |
|
| 457 | 462 | |
| 458 | 463 | $this->parseStatusCode($rawMessage); |
| 459 | 464 | |
@@ -467,8 +472,9 @@ discard block |
||
| 467 | 472 | |
| 468 | 473 | $rawMessage = preg_split('/\r\n\r\n/', $rawMessage, 2); |
| 469 | 474 | |
| 470 | - if (empty($rawMessage)) |
|
| 471 | - throw new \RuntimeException("The server didn't return a valid Response for the Request."); |
|
| 475 | + if (empty($rawMessage)) { |
|
| 476 | + throw new \RuntimeException("The server didn't return a valid Response for the Request."); |
|
| 477 | + } |
|
| 472 | 478 | |
| 473 | 479 | // $rawMessage[0] contains header fields. |
| 474 | 480 | $this->parseHeaderFields($rawMessage[0]); |
@@ -494,9 +500,9 @@ discard block |
||
| 494 | 500 | public function setStatusCode($value) { |
| 495 | 501 | if (array_key_exists($value, self::$supportedStatusCodes)) { |
| 496 | 502 | $this->statusCode = $value; |
| 503 | + } else { |
|
| 504 | + throw new \UnexpectedValueException("Status Code $value is not supported."); |
|
| 497 | 505 | } |
| 498 | - else |
|
| 499 | - throw new \UnexpectedValueException("Status Code $value is not supported."); |
|
| 500 | 506 | } |
| 501 | 507 | |
| 502 | 508 | |
@@ -515,12 +521,13 @@ discard block |
||
| 515 | 521 | * @param[in] string $description A description for the Status Code. |
| 516 | 522 | */ |
| 517 | 523 | public static function addCustomStatusCode($code, $description) { |
| 518 | - if (in_array($code, self::$supportedStatusCodes)) |
|
| 519 | - throw new \UnexpectedValueException("Status Code $code is supported and already exists."); |
|
| 520 | - elseif (is_int($code) and $code > 0) |
|
| 521 | - self::$supportedStatusCodes[$code] = $description; |
|
| 522 | - else |
|
| 523 | - throw new \InvalidArgumentException("\$code must be a positive integer."); |
|
| 524 | + if (in_array($code, self::$supportedStatusCodes)) { |
|
| 525 | + throw new \UnexpectedValueException("Status Code $code is supported and already exists."); |
|
| 526 | + } elseif (is_int($code) and $code > 0) { |
|
| 527 | + self::$supportedStatusCodes[$code] = $description; |
|
| 528 | + } else { |
|
| 529 | + throw new \InvalidArgumentException("\$code must be a positive integer."); |
|
| 530 | + } |
|
| 524 | 531 | } |
| 525 | 532 | |
| 526 | 533 | } |
| 527 | 534 | \ No newline at end of file |
@@ -206,8 +206,9 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function getHeaderAsArray() { |
| 208 | 208 | $wellformedHeader = []; |
| 209 | - foreach ($this->header as $name => $value) |
|
| 210 | - $wellformedHeader[] = $name.": ".$value; |
|
| 209 | + foreach ($this->header as $name => $value) { |
|
| 210 | + $wellformedHeader[] = $name.": ".$value; |
|
| 211 | + } |
|
| 211 | 212 | |
| 212 | 213 | return $wellformedHeader; |
| 213 | 214 | } |
@@ -238,10 +239,11 @@ discard block |
||
| 238 | 239 | * @retval string |
| 239 | 240 | */ |
| 240 | 241 | public function getHeaderFieldValue($name) { |
| 241 | - if ($this->hasHeaderField($name)) |
|
| 242 | - return $this->header[$name]; |
|
| 243 | - else |
|
| 244 | - return FALSE; |
|
| 242 | + if ($this->hasHeaderField($name)) { |
|
| 243 | + return $this->header[$name]; |
|
| 244 | + } else { |
|
| 245 | + return FALSE; |
|
| 246 | + } |
|
| 245 | 247 | } |
| 246 | 248 | |
| 247 | 249 | |
@@ -251,10 +253,11 @@ discard block |
||
| 251 | 253 | * @param[in] string $value The header field value. |
| 252 | 254 | */ |
| 253 | 255 | public function setHeaderField($name, $value) { |
| 254 | - if (array_key_exists($name, static::$supportedHeaderFields)) |
|
| 255 | - $this->header[$name] = $value; |
|
| 256 | - else |
|
| 257 | - throw new \Exception("$name header field is not supported."); |
|
| 256 | + if (array_key_exists($name, static::$supportedHeaderFields)) { |
|
| 257 | + $this->header[$name] = $value; |
|
| 258 | + } else { |
|
| 259 | + throw new \Exception("$name header field is not supported."); |
|
| 260 | + } |
|
| 258 | 261 | } |
| 259 | 262 | |
| 260 | 263 | |
@@ -263,8 +266,9 @@ discard block |
||
| 263 | 266 | * @param[in] string $name The header field name. |
| 264 | 267 | */ |
| 265 | 268 | public function removeHeaderField($name) { |
| 266 | - if (array_key_exists($name, static::$supportedHeaderFields)) |
|
| 267 | - unset($this->header[$name]); |
|
| 269 | + if (array_key_exists($name, static::$supportedHeaderFields)) { |
|
| 270 | + unset($this->header[$name]); |
|
| 271 | + } |
|
| 268 | 272 | } |
| 269 | 273 | |
| 270 | 274 | |
@@ -273,11 +277,12 @@ discard block |
||
| 273 | 277 | * @param[in] array $headerFields An associative array of header fields. |
| 274 | 278 | */ |
| 275 | 279 | public function setMultipleHeaderFieldsAtOnce(array $headerFields) { |
| 276 | - if (Helper\ArrayHelper::isAssociative($headerFields)) |
|
| 277 | - foreach ($headerFields as $name => $value) |
|
| 280 | + if (Helper\ArrayHelper::isAssociative($headerFields)) { |
|
| 281 | + foreach ($headerFields as $name => $value) |
|
| 278 | 282 | $this->setHeaderField($name, $value); |
| 279 | - else |
|
| 280 | - throw new \Exception("\$headerFields must be an associative array."); |
|
| 283 | + } else { |
|
| 284 | + throw new \Exception("\$headerFields must be an associative array."); |
|
| 285 | + } |
|
| 281 | 286 | } |
| 282 | 287 | |
| 283 | 288 | |
@@ -286,10 +291,11 @@ discard block |
||
| 286 | 291 | * @param[in] string $name Header field name. |
| 287 | 292 | */ |
| 288 | 293 | public static function addCustomHeaderField($name) { |
| 289 | - if (array_key_exists($name, static::$supportedHeaderFields)) |
|
| 290 | - throw new \Exception("$name header field is supported but already exists."); |
|
| 291 | - else |
|
| 292 | - static::$supportedHeaderFields[] = $name; |
|
| 294 | + if (array_key_exists($name, static::$supportedHeaderFields)) { |
|
| 295 | + throw new \Exception("$name header field is supported but already exists."); |
|
| 296 | + } else { |
|
| 297 | + static::$supportedHeaderFields[] = $name; |
|
| 298 | + } |
|
| 293 | 299 | } |
| 294 | 300 | |
| 295 | 301 | |
@@ -18,31 +18,35 @@ |
||
| 18 | 18 | trait TProperty { |
| 19 | 19 | |
| 20 | 20 | public function __get($name) { |
| 21 | - if (method_exists($this, ($method = 'get'.ucfirst($name)))) |
|
| 22 | - return $this->$method(); |
|
| 23 | - else |
|
| 24 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 21 | + if (method_exists($this, ($method = 'get'.ucfirst($name)))) { |
|
| 22 | + return $this->$method(); |
|
| 23 | + } else { |
|
| 24 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 25 | + } |
|
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | public function __isset($name) { |
| 28 | - if (method_exists($this, ($method = 'isset'.ucfirst($name)))) |
|
| 29 | - return $this->$method(); |
|
| 30 | - else |
|
| 31 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 29 | + if (method_exists($this, ($method = 'isset'.ucfirst($name)))) { |
|
| 30 | + return $this->$method(); |
|
| 31 | + } else { |
|
| 32 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 33 | + } |
|
| 32 | 34 | } |
| 33 | 35 | |
| 34 | 36 | public function __set($name, $value) { |
| 35 | - if (method_exists($this, ($method = 'set'.ucfirst($name)))) |
|
| 36 | - $this->$method($value); |
|
| 37 | - else |
|
| 38 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 37 | + if (method_exists($this, ($method = 'set'.ucfirst($name)))) { |
|
| 38 | + $this->$method($value); |
|
| 39 | + } else { |
|
| 40 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 41 | + } |
|
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | public function __unset($name) { |
| 42 | - if (method_exists($this, ($method = 'unset'.ucfirst($name)))) |
|
| 43 | - $this->$method(); |
|
| 44 | - else |
|
| 45 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 45 | + if (method_exists($this, ($method = 'unset'.ucfirst($name)))) { |
|
| 46 | + $this->$method(); |
|
| 47 | + } else { |
|
| 48 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 49 | + } |
|
| 46 | 50 | } |
| 47 | 51 | |
| 48 | 52 | } |
| 49 | 53 | \ No newline at end of file |