Conditions | 19 |
Paths | 39 |
Total Lines | 84 |
Code Lines | 59 |
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 |
||
120 | static public function fromXML(\XMLReader $xmlReader) |
||
121 | { |
||
122 | $endpoint = NULL; |
||
123 | $strategy = NULL; |
||
124 | $contentFormat = NULL; |
||
125 | $topicOwner = NULL; |
||
126 | $topicName = NULL; |
||
127 | $createTime = NULL; |
||
128 | $lastModifyTime = NULL; |
||
129 | |||
130 | while ($xmlReader->read()) |
||
131 | { |
||
132 | if ($xmlReader->nodeType == \XMLReader::ELEMENT) |
||
133 | { |
||
134 | switch ($xmlReader->name) { |
||
135 | case 'TopicOwner': |
||
136 | $xmlReader->read(); |
||
137 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
138 | { |
||
139 | $topicOwner = $xmlReader->value; |
||
140 | } |
||
141 | break; |
||
142 | case 'TopicName': |
||
143 | $xmlReader->read(); |
||
144 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
145 | { |
||
146 | $topicName = $xmlReader->value; |
||
147 | } |
||
148 | break; |
||
149 | case 'SubscriptionName': |
||
150 | $xmlReader->read(); |
||
151 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
152 | { |
||
153 | $subscriptionName = $xmlReader->value; |
||
154 | } |
||
155 | case 'Endpoint': |
||
156 | $xmlReader->read(); |
||
157 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
158 | { |
||
159 | $endpoint = $xmlReader->value; |
||
160 | } |
||
161 | break; |
||
162 | case 'NotifyStrategy': |
||
163 | $xmlReader->read(); |
||
164 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
165 | { |
||
166 | $strategy = $xmlReader->value; |
||
167 | } |
||
168 | break; |
||
169 | case 'NotifyContentFormat': |
||
170 | $xmlReader->read(); |
||
171 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
172 | { |
||
173 | $contentFormat = $xmlReader->value; |
||
174 | } |
||
175 | break; |
||
176 | case 'CreateTime': |
||
177 | $xmlReader->read(); |
||
178 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
179 | { |
||
180 | $createTime = $xmlReader->value; |
||
181 | } |
||
182 | break; |
||
183 | case 'LastModifyTime': |
||
184 | $xmlReader->read(); |
||
185 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
186 | { |
||
187 | $lastModifyTime = $xmlReader->value; |
||
188 | } |
||
189 | break; |
||
190 | } |
||
191 | } |
||
192 | } |
||
193 | |||
194 | $attributes = new SubscriptionAttributes( |
||
195 | $subscriptionName, |
||
196 | $endpoint, |
||
197 | $strategy, |
||
198 | $contentFormat, |
||
199 | $topicName, |
||
200 | $topicOwner, |
||
201 | $createTime, |
||
202 | $lastModifyTime); |
||
203 | return $attributes; |
||
204 | } |
||
208 |