@@ -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 | |
@@ -113,8 +116,9 @@ discard block |
||
| 113 | 116 | JSON_PRESERVE_ZERO_FRACTION |
| 114 | 117 | ); |
| 115 | 118 | |
| 116 | - if ($json === FALSE) |
|
| 117 | - throw new \RuntimeException(json_last_error_msg()); |
|
| 119 | + if ($json === FALSE) { |
|
| 120 | + throw new \RuntimeException(json_last_error_msg()); |
|
| 121 | + } |
|
| 118 | 122 | } |
| 119 | 123 | |
| 120 | 124 | |
@@ -154,8 +158,9 @@ discard block |
||
| 154 | 158 | |
| 155 | 159 | |
| 156 | 160 | public function unsetId() { |
| 157 | - if ($this->isMetadataPresent('_id')) |
|
| 158 | - unset($this->meta['_id']); |
|
| 161 | + if ($this->isMetadataPresent('_id')) { |
|
| 162 | + unset($this->meta['_id']); |
|
| 163 | + } |
|
| 159 | 164 | } |
| 160 | 165 | |
| 161 | 166 | |
@@ -175,8 +180,9 @@ discard block |
||
| 175 | 180 | |
| 176 | 181 | |
| 177 | 182 | public function unsetRev() { |
| 178 | - if ($this->isMetadataPresent('_rev')) |
|
| 179 | - unset($this->meta['_rev']); |
|
| 183 | + if ($this->isMetadataPresent('_rev')) { |
|
| 184 | + unset($this->meta['_rev']); |
|
| 185 | + } |
|
| 180 | 186 | } |
| 181 | 187 | |
| 182 | 188 | } |
| 183 | 189 | \ No newline at end of file |