@@ -44,19 +44,22 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) { |
| 47 | - if (is_null($value) && !$allowNull) |
|
| 48 | - return; |
|
| 47 | + if (is_null($value) && !$allowNull) { |
|
| 48 | + return; |
|
| 49 | + } |
|
| 49 | 50 | |
| 50 | - if ($this->isMetadataPresent($name) && !$override) |
|
| 51 | - return; |
|
| 51 | + if ($this->isMetadataPresent($name) && !$override) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 52 | 54 | |
| 53 | 55 | $this->meta[$name] = $value; |
| 54 | 56 | } |
| 55 | 57 | |
| 56 | 58 | |
| 57 | 59 | public function unsetMetadata($name) { |
| 58 | - if (array_key_exists($name, $this->meta)) |
|
| 59 | - unset($this->meta[$name]); |
|
| 60 | + if (array_key_exists($name, $this->meta)) { |
|
| 61 | + unset($this->meta[$name]); |
|
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | |
| 62 | 65 | |
@@ -68,9 +71,9 @@ discard block |
||
| 68 | 71 | public function assignArray(array $array) { |
| 69 | 72 | if (ArrayHelper::isAssociative($array)) { |
| 70 | 73 | $this->meta = array_merge($this->meta, $array); |
| 74 | + } else { |
|
| 75 | + throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 71 | 76 | } |
| 72 | - else |
|
| 73 | - throw new \InvalidArgumentException("\$array must be an associative array."); |
|
| 74 | 77 | } |
| 75 | 78 | |
| 76 | 79 | |
@@ -90,8 +93,9 @@ discard block |
||
| 90 | 93 | JSON_PRESERVE_ZERO_FRACTION |
| 91 | 94 | ); |
| 92 | 95 | |
| 93 | - if ($json === FALSE) |
|
| 94 | - throw new JSONErrorException(json_last_error_msg()); |
|
| 96 | + if ($json === FALSE) { |
|
| 97 | + throw new JSONErrorException(json_last_error_msg()); |
|
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | return $json; |
| 97 | 101 | } |