@@ -49,19 +49,22 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) { |
| 52 | - if (is_null($value) && !$allowNull) |
|
| 53 | - return; |
|
| 52 | + if (is_null($value) && !$allowNull) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 54 | 55 | |
| 55 | - if ($this->isMetadataPresent($name) && !$override) |
|
| 56 | - return; |
|
| 56 | + if ($this->isMetadataPresent($name) && !$override) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | 60 | $this->meta[$name] = $value; |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | |
| 62 | 64 | public function unsetMetadata($name) { |
| 63 | - if (array_key_exists($name, $this->meta)) |
|
| 64 | - unset($this->meta[$name]); |
|
| 65 | + if (array_key_exists($name, $this->meta)) { |
|
| 66 | + unset($this->meta[$name]); |
|
| 67 | + } |
|
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | |
@@ -95,9 +98,9 @@ discard block |
||
| 95 | 98 | if (Helper\ArrayHelper::isAssociative($array)) { |
| 96 | 99 | $this->meta = array_merge($this->meta, $array); |
| 97 | 100 | $this->fixDocId(); |
| 101 | + } else { |
|
| 102 | + throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 98 | 103 | } |
| 99 | - else |
|
| 100 | - throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 101 | 104 | } |
| 102 | 105 | |
| 103 | 106 | |
@@ -114,8 +117,9 @@ discard block |
||
| 114 | 117 | JSON_PRESERVE_ZERO_FRACTION |
| 115 | 118 | ); |
| 116 | 119 | |
| 117 | - if ($json === FALSE) |
|
| 118 | - throw new JSONErrorException(json_last_error_msg()); |
|
| 120 | + if ($json === FALSE) { |
|
| 121 | + throw new JSONErrorException(json_last_error_msg()); |
|
| 122 | + } |
|
| 119 | 123 | |
| 120 | 124 | return $json; |
| 121 | 125 | } |
@@ -157,8 +161,9 @@ discard block |
||
| 157 | 161 | |
| 158 | 162 | |
| 159 | 163 | public function unsetId() { |
| 160 | - if ($this->isMetadataPresent('_id')) |
|
| 161 | - unset($this->meta['_id']); |
|
| 164 | + if ($this->isMetadataPresent('_id')) { |
|
| 165 | + unset($this->meta['_id']); |
|
| 166 | + } |
|
| 162 | 167 | } |
| 163 | 168 | |
| 164 | 169 | |
@@ -178,8 +183,9 @@ discard block |
||
| 178 | 183 | |
| 179 | 184 | |
| 180 | 185 | public function unsetRev() { |
| 181 | - if ($this->isMetadataPresent('_rev')) |
|
| 182 | - unset($this->meta['_rev']); |
|
| 186 | + if ($this->isMetadataPresent('_rev')) { |
|
| 187 | + unset($this->meta['_rev']); |
|
| 188 | + } |
|
| 183 | 189 | } |
| 184 | 190 | |
| 185 | 191 | } |
| 186 | 192 | \ No newline at end of file |