| Conditions | 11 |
| Paths | 11 |
| Total Lines | 50 |
| 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 |
||
| 118 | public function next() |
||
| 119 | { |
||
| 120 | $this->valid = false; |
||
| 121 | |||
| 122 | $style = null; |
||
| 123 | $type = null; |
||
| 124 | $columnIndex = null; |
||
| 125 | $rowBuilder = null; |
||
| 126 | $currentKey = 0; |
||
| 127 | |||
| 128 | while ($this->xml->read()) { |
||
| 129 | if (\XMLReader::ELEMENT === $this->xml->nodeType) { |
||
| 130 | switch ($this->xml->name) { |
||
| 131 | case 'row': |
||
| 132 | $currentKey = (int)$this->xml->getAttribute('r'); |
||
| 133 | $rowBuilder = $this->rowBuilderFactory->create(); |
||
| 134 | break; |
||
| 135 | case 'c': |
||
| 136 | $columnIndex = $this->columnIndexTransformer->transform($this->xml->getAttribute('r')); |
||
| 137 | $style = $this->getValue($this->xml->getAttribute('s')); |
||
| 138 | $type = $this->getValue($this->xml->getAttribute('t')); |
||
| 139 | break; |
||
| 140 | case 'v': |
||
| 141 | $rowBuilder->addValue( |
||
| 142 | $columnIndex, |
||
| 143 | $this->valueTransformer->transform($this->xml->readString(), $type, $style) |
||
| 144 | ); |
||
| 145 | break; |
||
| 146 | case 'is': |
||
| 147 | $rowBuilder->addValue($columnIndex, $this->xml->readString()); |
||
| 148 | break; |
||
| 149 | } |
||
| 150 | } elseif (\XMLReader::END_ELEMENT === $this->xml->nodeType) { |
||
| 151 | switch ($this->xml->name) { |
||
| 152 | case 'row': |
||
| 153 | $currentValue = $rowBuilder->getData(); |
||
| 154 | if (count($currentValue)) { |
||
| 155 | $this->currentKey = $currentKey; |
||
| 156 | $this->currentValue = $currentValue; |
||
| 157 | $this->valid = true; |
||
| 158 | |||
| 159 | return; |
||
| 160 | } |
||
| 161 | break; |
||
| 162 | case 'sheetData': |
||
| 163 | break 2; |
||
| 164 | } |
||
| 165 | } |
||
| 166 | } |
||
| 167 | } |
||
| 168 | |||
| 202 |