@@ -65,11 +65,13 @@ discard block |
||
| 65 | 65 | * @param[in] bool $allowNull When `true` allows a `null` value. |
| 66 | 66 | */ |
| 67 | 67 | public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) { |
| 68 | - if (is_null($value) && !$allowNull) |
|
| 69 | - return; |
|
| 68 | + if (is_null($value) && !$allowNull) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 70 | 71 | |
| 71 | - if ($this->isMetadataPresent($name) && !$override) |
|
| 72 | - return; |
|
| 72 | + if ($this->isMetadataPresent($name) && !$override) { |
|
| 73 | + return; |
|
| 74 | + } |
|
| 73 | 75 | |
| 74 | 76 | $this->meta[$name] = $value; |
| 75 | 77 | } |
@@ -80,8 +82,9 @@ discard block |
||
| 80 | 82 | * @param[in] string $name The metadata name. |
| 81 | 83 | */ |
| 82 | 84 | public function unsetMetadata($name) { |
| 83 | - if (array_key_exists($name, $this->meta)) |
|
| 84 | - unset($this->meta[$name]); |
|
| 85 | + if (array_key_exists($name, $this->meta)) { |
|
| 86 | + unset($this->meta[$name]); |
|
| 87 | + } |
|
| 85 | 88 | } |
| 86 | 89 | |
| 87 | 90 | |
@@ -102,9 +105,9 @@ discard block |
||
| 102 | 105 | public function assignArray(array $array) { |
| 103 | 106 | if (ArrayHelper::isAssociative($array)) { |
| 104 | 107 | $this->meta = array_merge($this->meta, $array); |
| 108 | + } else { |
|
| 109 | + throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 105 | 110 | } |
| 106 | - else |
|
| 107 | - throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 108 | 111 | } |
| 109 | 112 | |
| 110 | 113 | |
@@ -128,8 +131,9 @@ discard block |
||
| 128 | 131 | JSON_PRESERVE_ZERO_FRACTION |
| 129 | 132 | ); |
| 130 | 133 | |
| 131 | - if ($json === FALSE) |
|
| 132 | - throw new JSONErrorException(json_last_error_msg()); |
|
| 134 | + if ($json === FALSE) { |
|
| 135 | + throw new JSONErrorException(json_last_error_msg()); |
|
| 136 | + } |
|
| 133 | 137 | |
| 134 | 138 | return $json; |
| 135 | 139 | } |