Conditions | 10 |
Paths | 22 |
Total Lines | 39 |
Code Lines | 25 |
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 |
||
34 | public function parseResponse($statusCode, $content) |
||
35 | { |
||
36 | $this->statusCode = $statusCode; |
||
37 | if ($statusCode != 200) { |
||
38 | $this->parseErrorResponse($statusCode, $content); |
||
39 | return; |
||
40 | } |
||
41 | |||
42 | $this->succeed = TRUE; |
||
43 | $xmlReader = $this->loadXmlContent($content); |
||
44 | |||
45 | try { |
||
46 | while ($xmlReader->read()) |
||
47 | { |
||
48 | if ($xmlReader->nodeType == \XMLReader::ELEMENT) |
||
49 | { |
||
50 | switch ($xmlReader->name) { |
||
51 | case 'QueueURL': |
||
52 | $xmlReader->read(); |
||
53 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
54 | { |
||
55 | $queueName = $this->getQueueNameFromQueueURL($xmlReader->value); |
||
56 | $this->queueNames[] = $queueName; |
||
57 | } |
||
58 | break; |
||
59 | case 'NextMarker': |
||
60 | $xmlReader->read(); |
||
61 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
62 | { |
||
63 | $this->nextMarker = $xmlReader->value; |
||
64 | } |
||
65 | break; |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | } catch (\Exception $e) { |
||
70 | throw new MnsException($statusCode, $e->getMessage(), $e); |
||
71 | } catch (\Throwable $t) { |
||
72 | throw new MnsException($statusCode, $t->getMessage()); |
||
73 | } |
||
110 |