@@ -68,11 +68,13 @@ discard block |
||
68 | 68 | * @param bool $allowNull When `true` allows a `null` value. |
69 | 69 | */ |
70 | 70 | public function setMetadata($name, $value, $override = TRUE, $allowNull = TRUE) { |
71 | - if (is_null($value) && !$allowNull) |
|
72 | - return; |
|
71 | + if (is_null($value) && !$allowNull) { |
|
72 | + return; |
|
73 | + } |
|
73 | 74 | |
74 | - if ($this->isMetadataPresent($name) && !$override) |
|
75 | - return; |
|
75 | + if ($this->isMetadataPresent($name) && !$override) { |
|
76 | + return; |
|
77 | + } |
|
76 | 78 | |
77 | 79 | $this->meta[$name] = $value; |
78 | 80 | } |
@@ -83,8 +85,9 @@ discard block |
||
83 | 85 | * @param string $name The metadata name. |
84 | 86 | */ |
85 | 87 | public function unsetMetadata($name) { |
86 | - if (array_key_exists($name, $this->meta)) |
|
87 | - unset($this->meta[$name]); |
|
88 | + if (array_key_exists($name, $this->meta)) { |
|
89 | + unset($this->meta[$name]); |
|
90 | + } |
|
88 | 91 | } |
89 | 92 | |
90 | 93 | |
@@ -106,9 +109,9 @@ discard block |
||
106 | 109 | public function assignArray(array $array) { |
107 | 110 | if (ArrayHelper::isAssociative($array)) { |
108 | 111 | $this->meta = array_merge($this->meta, $array); |
112 | + } else { |
|
113 | + throw new InvalidArgumentException("\$array must be an associative array."); |
|
109 | 114 | } |
110 | - else |
|
111 | - throw new InvalidArgumentException("\$array must be an associative array."); |
|
112 | 115 | } |
113 | 116 | |
114 | 117 | |
@@ -133,8 +136,9 @@ discard block |
||
133 | 136 | JSON_PRESERVE_ZERO_FRACTION |
134 | 137 | ); |
135 | 138 | |
136 | - if ($json === FALSE) |
|
137 | - throw new JSONErrorException(json_last_error_msg()); |
|
139 | + if ($json === FALSE) { |
|
140 | + throw new JSONErrorException(json_last_error_msg()); |
|
141 | + } |
|
138 | 142 | |
139 | 143 | return $json; |
140 | 144 | } |
@@ -113,7 +113,7 @@ |
||
113 | 113 | * @param integer $offset The offset to retrieve. |
114 | 114 | * @return mixed Can return all value types. |
115 | 115 | */ |
116 | - public function offsetGet($offset) { |
|
116 | + public function offsetGet($offset) { |
|
117 | 117 | return $this->meta[$this->name][$offset]; |
118 | 118 | } |
119 | 119 |