@@ -18,31 +18,35 @@ |
||
| 18 | 18 | trait TProperty { |
| 19 | 19 | |
| 20 | 20 | public function __get($name) { |
| 21 | - if (method_exists($this, ($method = 'get'.ucfirst($name)))) |
|
| 22 | - return $this->$method(); |
|
| 23 | - else |
|
| 24 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 21 | + if (method_exists($this, ($method = 'get'.ucfirst($name)))) { |
|
| 22 | + return $this->$method(); |
|
| 23 | + } else { |
|
| 24 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 25 | + } |
|
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | public function __isset($name) { |
| 28 | - if (method_exists($this, ($method = 'isset'.ucfirst($name)))) |
|
| 29 | - return $this->$method(); |
|
| 30 | - else |
|
| 31 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 29 | + if (method_exists($this, ($method = 'isset'.ucfirst($name)))) { |
|
| 30 | + return $this->$method(); |
|
| 31 | + } else { |
|
| 32 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 33 | + } |
|
| 32 | 34 | } |
| 33 | 35 | |
| 34 | 36 | public function __set($name, $value) { |
| 35 | - if (method_exists($this, ($method = 'set'.ucfirst($name)))) |
|
| 36 | - $this->$method($value); |
|
| 37 | - else |
|
| 38 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 37 | + if (method_exists($this, ($method = 'set'.ucfirst($name)))) { |
|
| 38 | + $this->$method($value); |
|
| 39 | + } else { |
|
| 40 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 41 | + } |
|
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | public function __unset($name) { |
| 42 | - if (method_exists($this, ($method = 'unset'.ucfirst($name)))) |
|
| 43 | - $this->$method(); |
|
| 44 | - else |
|
| 45 | - throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 45 | + if (method_exists($this, ($method = 'unset'.ucfirst($name)))) { |
|
| 46 | + $this->$method(); |
|
| 47 | + } else { |
|
| 48 | + throw new \BadMethodCallException("Method $method is not implemented for property $name."); |
|
| 49 | + } |
|
| 46 | 50 | } |
| 47 | 51 | |
| 48 | 52 | } |
| 49 | 53 | \ No newline at end of file |
@@ -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 | |