Conditions | 16 |
Paths | 16 |
Total Lines | 76 |
Code Lines | 51 |
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 |
||
100 | static public function fromXML(\XMLReader $xmlReader) |
||
101 | { |
||
102 | $maximumMessageSize = NULL; |
||
103 | $messageRetentionPeriod = NULL; |
||
104 | $topicName = NULL; |
||
105 | $createTime = NULL; |
||
106 | $lastModifyTime = NULL; |
||
107 | $loggingEnabled = NULL; |
||
108 | |||
109 | while ($xmlReader->read()) |
||
110 | { |
||
111 | if ($xmlReader->nodeType == \XMLReader::ELEMENT) |
||
112 | { |
||
113 | switch ($xmlReader->name) { |
||
114 | case 'MaximumMessageSize': |
||
115 | $xmlReader->read(); |
||
116 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
117 | { |
||
118 | $maximumMessageSize = $xmlReader->value; |
||
119 | } |
||
120 | break; |
||
121 | case 'MessageRetentionPeriod': |
||
122 | $xmlReader->read(); |
||
123 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
124 | { |
||
125 | $messageRetentionPeriod = $xmlReader->value; |
||
126 | } |
||
127 | break; |
||
128 | case 'TopicName': |
||
129 | $xmlReader->read(); |
||
130 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
131 | { |
||
132 | $topicName = $xmlReader->value; |
||
133 | } |
||
134 | break; |
||
135 | case 'CreateTime': |
||
136 | $xmlReader->read(); |
||
137 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
138 | { |
||
139 | $createTime = $xmlReader->value; |
||
140 | } |
||
141 | break; |
||
142 | case 'LastModifyTime': |
||
143 | $xmlReader->read(); |
||
144 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
145 | { |
||
146 | $lastModifyTime = $xmlReader->value; |
||
147 | } |
||
148 | break; |
||
149 | case 'LoggingEnabled': |
||
150 | $xmlReader->read(); |
||
151 | if ($xmlReader->nodeType == \XMLReader::TEXT) |
||
152 | { |
||
153 | $loggingEnabled = $xmlReader->value; |
||
154 | if ($loggingEnabled == "True") |
||
155 | { |
||
156 | $loggingEnabled = True; |
||
157 | } |
||
158 | else |
||
159 | { |
||
160 | $loggingEnabled = False; |
||
161 | } |
||
162 | } |
||
163 | break; |
||
164 | } |
||
165 | } |
||
166 | } |
||
167 | |||
168 | $attributes = new TopicAttributes( |
||
169 | $maximumMessageSize, |
||
170 | $messageRetentionPeriod, |
||
171 | $topicName, |
||
172 | $createTime, |
||
173 | $lastModifyTime, |
||
174 | $loggingEnabled); |
||
175 | return $attributes; |
||
176 | } |
||
180 |