Conditions | 10 |
Paths | 22 |
Total Lines | 44 |
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 | { |
||
47 | while ($xmlReader->read()) |
||
48 | { |
||
49 | if ($xmlReader->nodeType == \XMLReader::ELEMENT) |
||
50 | { |
||
51 | switch ($xmlReader->name) { |
||
52 | case 'TopicURL': |
||
53 | $xmlReader->read(); |
||
54 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
55 | { |
||
56 | $topicName = $this->getTopicNameFromTopicURL($xmlReader->value); |
||
57 | $this->topicNames[] = $topicName; |
||
58 | } |
||
59 | break; |
||
60 | case 'NextMarker': |
||
61 | $xmlReader->read(); |
||
62 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
63 | { |
||
64 | $this->nextMarker = $xmlReader->value; |
||
65 | } |
||
66 | break; |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | } |
||
71 | catch (\Exception $e) |
||
72 | { |
||
73 | throw new MnsException($statusCode, $e->getMessage(), $e); |
||
74 | } |
||
75 | catch (\Throwable $t) |
||
76 | { |
||
77 | throw new MnsException($statusCode, $t->getMessage()); |
||
78 | } |
||
125 |