@@ -38,8 +38,9 @@ |
||
| 38 | 38 | { |
| 39 | 39 | foreach ($attributes as $name => $value) |
| 40 | 40 | { |
| 41 | - if (!is_string($name)) |
|
| 42 | - throw new \InvalidArgumentException("Attribute only accepts strings as names"); |
|
| 41 | + if (!is_string($name)) { |
|
| 42 | + throw new \InvalidArgumentException("Attribute only accepts strings as names"); |
|
| 43 | + } |
|
| 43 | 44 | |
| 44 | 45 | $instance->setAttribute(new Attribute($name, $value)); |
| 45 | 46 | } |
@@ -258,12 +258,12 @@ |
||
| 258 | 258 | { |
| 259 | 259 | if (static::HAS_END_TAG) |
| 260 | 260 | { |
| 261 | - $this->startTag = "<" .strtolower(static::NODE_NAME). ">"; |
|
| 262 | - $this->endTag = "</" .strtolower(static::NODE_NAME). ">"; |
|
| 261 | + $this->startTag = "<" . strtolower(static::NODE_NAME) . ">"; |
|
| 262 | + $this->endTag = "</" . strtolower(static::NODE_NAME) . ">"; |
|
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
| 266 | - $this->startTag = "<" .strtolower(static::NODE_NAME); |
|
| 266 | + $this->startTag = "<" . strtolower(static::NODE_NAME); |
|
| 267 | 267 | $this->endTag = "/>"; |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -110,8 +110,9 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function hasChild($label) |
| 112 | 112 | { |
| 113 | - if (array_key_exists($label, $this->children)) |
|
| 114 | - return true; |
|
| 113 | + if (array_key_exists($label, $this->children)) { |
|
| 114 | + return true; |
|
| 115 | + } |
|
| 115 | 116 | |
| 116 | 117 | return false; |
| 117 | 118 | } |
@@ -125,8 +126,9 @@ discard block |
||
| 125 | 126 | */ |
| 126 | 127 | public function getChild($label) |
| 127 | 128 | { |
| 128 | - if (array_key_exists($label, $this->children)) |
|
| 129 | - return $this->children[$label]; |
|
| 129 | + if (array_key_exists($label, $this->children)) { |
|
| 130 | + return $this->children[$label]; |
|
| 131 | + } |
|
| 130 | 132 | |
| 131 | 133 | return null; |
| 132 | 134 | } |
@@ -155,10 +157,11 @@ discard block |
||
| 155 | 157 | */ |
| 156 | 158 | public function removeChild($label) |
| 157 | 159 | { |
| 158 | - if (array_key_exists($label, $this->children)) |
|
| 159 | - unset($this->children[$label]); |
|
| 160 | - else |
|
| 161 | - throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
| 160 | + if (array_key_exists($label, $this->children)) { |
|
| 161 | + unset($this->children[$label]); |
|
| 162 | + } else { |
|
| 163 | + throw new Exception\ChildNotFoundException("The child to remove does not exists"); |
|
| 164 | + } |
|
| 162 | 165 | } |
| 163 | 166 | |
| 164 | 167 | /** |
@@ -174,8 +177,9 @@ discard block |
||
| 174 | 177 | { |
| 175 | 178 | foreach ($this->attributes as $attrib) |
| 176 | 179 | { |
| 177 | - if ($attrib->getName() == $name) |
|
| 178 | - return true; |
|
| 180 | + if ($attrib->getName() == $name) { |
|
| 181 | + return true; |
|
| 182 | + } |
|
| 179 | 183 | } |
| 180 | 184 | } |
| 181 | 185 | |
@@ -195,8 +199,9 @@ discard block |
||
| 195 | 199 | { |
| 196 | 200 | foreach ($this->attributes as $attrib) |
| 197 | 201 | { |
| 198 | - if ($attrib->getName() == $name) |
|
| 199 | - return $attrib; |
|
| 202 | + if ($attrib->getName() == $name) { |
|
| 203 | + return $attrib; |
|
| 204 | + } |
|
| 200 | 205 | } |
| 201 | 206 | } |
| 202 | 207 | |
@@ -218,12 +223,13 @@ discard block |
||
| 218 | 223 | { |
| 219 | 224 | foreach ($this->attributes as $key => $_attrib) |
| 220 | 225 | { |
| 221 | - if ($_attrib->getName() == $attrib->getName()) |
|
| 222 | - $this->attributes[$key] = $attribute; |
|
| 226 | + if ($_attrib->getName() == $attrib->getName()) { |
|
| 227 | + $this->attributes[$key] = $attribute; |
|
| 228 | + } |
|
| 223 | 229 | } |
| 230 | + } else { |
|
| 231 | + $this->attributes[] = $attribute; |
|
| 224 | 232 | } |
| 225 | - else |
|
| 226 | - $this->attributes[] = $attribute; |
|
| 227 | 233 | } |
| 228 | 234 | |
| 229 | 235 | /** |
@@ -241,8 +247,9 @@ discard block |
||
| 241 | 247 | { |
| 242 | 248 | foreach ($this->attributes as $key => $attrib) |
| 243 | 249 | { |
| 244 | - if ($attrib->getName() == $name) |
|
| 245 | - unset($this->attributes[$key]); |
|
| 250 | + if ($attrib->getName() == $name) { |
|
| 251 | + unset($this->attributes[$key]); |
|
| 252 | + } |
|
| 246 | 253 | } |
| 247 | 254 | } |
| 248 | 255 | |
@@ -260,8 +267,7 @@ discard block |
||
| 260 | 267 | { |
| 261 | 268 | $this->startTag = "<" .strtolower(static::NODE_NAME). ">"; |
| 262 | 269 | $this->endTag = "</" .strtolower(static::NODE_NAME). ">"; |
| 263 | - } |
|
| 264 | - else |
|
| 270 | + } else |
|
| 265 | 271 | { |
| 266 | 272 | $this->startTag = "<" .strtolower(static::NODE_NAME); |
| 267 | 273 | $this->endTag = "/>"; |