| Conditions | 11 |
| Paths | 11 |
| Total Lines | 47 |
| Code Lines | 29 |
| Lines | 21 |
| Ratio | 44.68 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 34 | static public function fromXML($xmlReader) |
||
| 35 | { |
||
| 36 | $errorCode = NULL; |
||
| 37 | $errorMessage = NULL; |
||
| 38 | $receiptHandle = NULL; |
||
| 39 | |||
| 40 | while ($xmlReader->read()) |
||
| 41 | { |
||
| 42 | switch ($xmlReader->nodeType) |
||
| 43 | { |
||
| 44 | case \XMLReader::ELEMENT: |
||
| 45 | switch ($xmlReader->name) |
||
| 46 | { |
||
| 47 | case Constants::ERROR_CODE: |
||
| 48 | $xmlReader->read(); |
||
| 49 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 50 | { |
||
| 51 | $errorCode = $xmlReader->value; |
||
| 52 | } |
||
| 53 | break; |
||
| 54 | case Constants::ERROR_MESSAGE: |
||
| 55 | $xmlReader->read(); |
||
| 56 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 57 | { |
||
| 58 | $errorMessage = $xmlReader->value; |
||
| 59 | } |
||
| 60 | break; |
||
| 61 | case Constants::RECEIPT_HANDLE: |
||
| 62 | $xmlReader->read(); |
||
| 63 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
| 64 | { |
||
| 65 | $receiptHandle = $xmlReader->value; |
||
| 66 | } |
||
| 67 | break; |
||
| 68 | } |
||
| 69 | break; |
||
| 70 | case \XMLReader::END_ELEMENT: |
||
| 71 | if ($xmlReader->name == Constants::ERROR) |
||
| 72 | { |
||
| 73 | return new DeleteMessageErrorItem($errorCode, $errorMessage, $receiptHandle); |
||
| 74 | } |
||
| 75 | break; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | return new DeleteMessageErrorItem($errorCode, $errorMessage, $receiptHandle); |
||
| 80 | } |
||
| 81 | } |
||
| 84 |