| Conditions | 21 |
| Paths | 20 |
| Total Lines | 46 |
| 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 |
||
| 134 | public function endXML($parser, $name) |
||
| 135 | { |
||
| 136 | --$this->xml_depth; |
||
| 137 | if ($this->xml_depth === 1) { |
||
| 138 | foreach ($this->xpathhandlers as $handler) { |
||
| 139 | if (is_array($this->xmlobj) && array_key_exists(2, $this->xmlobj)) { |
||
| 140 | $searchxml = $this->xmlobj[2]; |
||
| 141 | $nstag = array_shift($handler[0]); |
||
| 142 | if (($nstag[0] === null or $searchxml->ns === $nstag[0]) and ($nstag[1] === "*" or $nstag[1] === $searchxml->name)) { |
||
| 143 | foreach ($handler[0] as $nstag) { |
||
| 144 | if ($searchxml !== null and $searchxml->hasSub($nstag[1], $ns = $nstag[0])) { |
||
| 145 | $searchxml = $searchxml->sub($nstag[1], $ns = $nstag[0]); |
||
| 146 | } else { |
||
| 147 | $searchxml = null; |
||
| 148 | break; |
||
| 149 | } |
||
| 150 | } |
||
| 151 | if ($searchxml !== null) { |
||
| 152 | if ($handler[2] === null) { |
||
| 153 | $handler[2] = $this; |
||
| 154 | } |
||
| 155 | $handler[1]($this->xmlobj[2]); |
||
| 156 | } |
||
| 157 | } |
||
| 158 | } |
||
| 159 | } |
||
| 160 | foreach ($this->idhandlers as $id => $handler) { |
||
| 161 | if (array_key_exists('id', $this->xmlobj[2]->attrs) and $this->xmlobj[2]->attrs['id'] == $id) { |
||
| 162 | $handler($this->xmlobj[2]); |
||
| 163 | #id handlers are only used once |
||
| 164 | unset($this->idhandlers[$id]); |
||
| 165 | break; |
||
| 166 | } |
||
| 167 | } |
||
| 168 | if (is_array($this->xmlobj)) { |
||
| 169 | $this->xmlobj = array_slice($this->xmlobj, 0, 1); |
||
| 170 | if (isset($this->xmlobj[0]) && $this->xmlobj[0] instanceof XMLStreamObject) { |
||
| 171 | $this->xmlobj[0]->subs = null; |
||
| 172 | } |
||
| 173 | } |
||
| 174 | unset($this->xmlobj[2]); |
||
| 175 | } |
||
| 176 | if ($this->xml_depth === 0) { |
||
| 177 | $this->event('streamEnd'); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | |||
| 246 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.