Conditions | 13 |
Paths | 15 |
Total Lines | 61 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
107 | protected function parse_request_data() |
||
108 | { |
||
109 | if (empty($this->raw_request)) |
||
110 | { |
||
111 | throw new Exception\Structure('An empty xml request', -50); |
||
112 | } |
||
113 | |||
114 | libxml_use_internal_errors(true); |
||
115 | $doc = new \DOMDocument(); |
||
116 | if ( ! $doc->loadXML($this->raw_request)) |
||
117 | { |
||
118 | foreach(libxml_get_errors() as $e){ |
||
119 | Log::instance()->error($e->message); |
||
120 | } |
||
121 | throw new Exception\Structure('The wrong XML is received', -51); |
||
122 | } |
||
123 | |||
124 | // process <Request> group |
||
125 | $r = $this->getNodes($doc, 'Request'); |
||
126 | |||
127 | if (count($r) < 1) |
||
128 | { |
||
129 | throw new Exception\Structure('The xml-query does not contain any element Request!', -52); |
||
130 | } |
||
131 | |||
132 | foreach ($r[0]->childNodes as $child) |
||
133 | { |
||
134 | if ($child->nodeName == 'DateTime') |
||
135 | { |
||
136 | $this->parse_request_node($child, 'DateTime'); |
||
137 | } |
||
138 | elseif ($child->nodeName == 'Sign') |
||
139 | { |
||
140 | $this->parse_request_node($child, 'Sign'); |
||
141 | } |
||
142 | elseif (in_array($child->nodeName, $this->operations)) |
||
143 | { |
||
144 | if ( ! isset($this->Operation)) |
||
145 | { |
||
146 | $this->Operation = $child->nodeName; |
||
147 | } |
||
148 | else |
||
149 | { |
||
150 | throw new Exception\Structure('There is more than one Operation type element in the xml-query!', -53); |
||
151 | } |
||
152 | } |
||
153 | } |
||
154 | |||
155 | if ( ! isset($this->Operation)) |
||
156 | { |
||
157 | throw new Exception\Structure('There is no Operation type element in the xml request!', -55); |
||
158 | } |
||
159 | |||
160 | // process <Operation> group |
||
161 | $r = $this->getNodes($doc, $this->Operation); |
||
162 | |||
163 | foreach ($r[0]->childNodes as $child) |
||
164 | { |
||
165 | if ($child->nodeName == 'ServiceId') |
||
166 | { |
||
167 | $this->parse_request_node($child, 'ServiceId'); |
||
168 | } |
||
288 |