| Conditions | 28 |
| Paths | 28 |
| Total Lines | 130 |
| Code Lines | 93 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 175 | static public function fromXML(\XMLReader $xmlReader) |
||
| 176 | { |
||
| 177 | $delaySeconds = NULL; |
||
| 178 | $maximumMessageSize = NULL; |
||
| 179 | $messageRetentionPeriod = NULL; |
||
| 180 | $visibilityTimeout = NULL; |
||
| 181 | $pollingWaitSeconds = NULL; |
||
| 182 | $queueName = NULL; |
||
| 183 | $createTime = NULL; |
||
| 184 | $lastModifyTime = NULL; |
||
| 185 | $activeMessages = NULL; |
||
| 186 | $inactiveMessages = NULL; |
||
| 187 | $delayMessages = NULL; |
||
| 188 | $loggingEnabled = NULL; |
||
| 189 | |||
| 190 | while ($xmlReader->read()) |
||
| 191 | { |
||
| 192 | if ($xmlReader->nodeType == \XMLReader::ELEMENT) |
||
| 193 | { |
||
| 194 | switch ($xmlReader->name) { |
||
| 195 | case 'DelaySeconds': |
||
| 196 | $xmlReader->read(); |
||
| 197 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 198 | { |
||
| 199 | $delaySeconds = $xmlReader->value; |
||
| 200 | } |
||
| 201 | break; |
||
| 202 | case 'MaximumMessageSize': |
||
| 203 | $xmlReader->read(); |
||
| 204 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 205 | { |
||
| 206 | $maximumMessageSize = $xmlReader->value; |
||
| 207 | } |
||
| 208 | break; |
||
| 209 | case 'MessageRetentionPeriod': |
||
| 210 | $xmlReader->read(); |
||
| 211 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 212 | { |
||
| 213 | $messageRetentionPeriod = $xmlReader->value; |
||
| 214 | } |
||
| 215 | break; |
||
| 216 | case 'VisibilityTimeout': |
||
| 217 | $xmlReader->read(); |
||
| 218 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 219 | { |
||
| 220 | $visibilityTimeout = $xmlReader->value; |
||
| 221 | } |
||
| 222 | break; |
||
| 223 | case 'PollingWaitSeconds': |
||
| 224 | $xmlReader->read(); |
||
| 225 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 226 | { |
||
| 227 | $pollingWaitSeconds = $xmlReader->value; |
||
| 228 | } |
||
| 229 | break; |
||
| 230 | case 'QueueName': |
||
| 231 | $xmlReader->read(); |
||
| 232 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 233 | { |
||
| 234 | $queueName = $xmlReader->value; |
||
| 235 | } |
||
| 236 | break; |
||
| 237 | case 'CreateTime': |
||
| 238 | $xmlReader->read(); |
||
| 239 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 240 | { |
||
| 241 | $createTime = $xmlReader->value; |
||
| 242 | } |
||
| 243 | break; |
||
| 244 | case 'LastModifyTime': |
||
| 245 | $xmlReader->read(); |
||
| 246 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 247 | { |
||
| 248 | $lastModifyTime = $xmlReader->value; |
||
| 249 | } |
||
| 250 | break; |
||
| 251 | case 'ActiveMessages': |
||
| 252 | $xmlReader->read(); |
||
| 253 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 254 | { |
||
| 255 | $activeMessages = $xmlReader->value; |
||
| 256 | } |
||
| 257 | break; |
||
| 258 | case 'InactiveMessages': |
||
| 259 | $xmlReader->read(); |
||
| 260 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 261 | { |
||
| 262 | $inactiveMessages = $xmlReader->value; |
||
| 263 | } |
||
| 264 | break; |
||
| 265 | case 'DelayMessages': |
||
| 266 | $xmlReader->read(); |
||
| 267 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 268 | { |
||
| 269 | $delayMessages = $xmlReader->value; |
||
| 270 | } |
||
| 271 | break; |
||
| 272 | case 'LoggingEnabled': |
||
| 273 | $xmlReader->read(); |
||
| 274 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 275 | { |
||
| 276 | $loggingEnabled = $xmlReader->value; |
||
| 277 | if ($loggingEnabled == "True") |
||
| 278 | { |
||
| 279 | $loggingEnabled = True; |
||
| 280 | } |
||
| 281 | else |
||
| 282 | { |
||
| 283 | $loggingEnabled = False; |
||
| 284 | } |
||
| 285 | } |
||
| 286 | break; |
||
| 287 | } |
||
| 288 | } |
||
| 289 | } |
||
| 290 | |||
| 291 | $attributes = new QueueAttributes( |
||
| 292 | $delaySeconds, |
||
| 293 | $maximumMessageSize, |
||
| 294 | $messageRetentionPeriod, |
||
| 295 | $visibilityTimeout, |
||
| 296 | $pollingWaitSeconds, |
||
| 297 | $queueName, |
||
| 298 | $createTime, |
||
| 299 | $lastModifyTime, |
||
| 300 | $activeMessages, |
||
| 301 | $inactiveMessages, |
||
| 302 | $delayMessages, |
||
| 303 | $loggingEnabled); |
||
| 304 | return $attributes; |
||
| 305 | } |
||
| 309 |