| Conditions | 7 |
| Paths | 14 |
| Total Lines | 53 |
| 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 |
||
| 169 | public function parseResults(LoopResult $loopResult) |
||
| 170 | { |
||
| 171 | $featureTypes = self::getFeaturesType($loopResult); |
||
| 172 | |||
| 173 | $slugs = array(); |
||
| 174 | |||
| 175 | /** @var FeatureType $featureType */ |
||
| 176 | foreach ($featureTypes as $featureType) { |
||
| 177 | $slugs[$featureType->getVirtualColumn('SLUG')] = true; |
||
| 178 | } |
||
| 179 | |||
| 180 | /** @var FeatureModel $feature */ |
||
| 181 | foreach ($loopResult->getResultDataCollection() as $feature) { |
||
| 182 | $loopResultRow = new LoopResultRow($feature); |
||
| 183 | $loopResultRow->set("ID", $feature->getId()) |
||
| 184 | ->set("IS_TRANSLATED", $feature->getVirtualColumn('IS_TRANSLATED')) |
||
| 185 | ->set("LOCALE", $this->locale) |
||
| 186 | ->set("TITLE", $feature->getVirtualColumn('i18n_TITLE')) |
||
| 187 | ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) |
||
| 188 | ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) |
||
| 189 | ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')) |
||
| 190 | ->set("POSITION", $this->useFeaturePosition ? $feature->getPosition() : $feature->getVirtualColumn('position')) |
||
| 191 | ; |
||
| 192 | |||
| 193 | // init slug variable |
||
| 194 | foreach ($slugs as $slug => $bool) { |
||
| 195 | $loopResultRow->set( |
||
| 196 | self::formatSlug( |
||
| 197 | $slug |
||
| 198 | ), |
||
| 199 | null |
||
| 200 | ); |
||
| 201 | } |
||
| 202 | |||
| 203 | /** @var FeatureFeatureType $featureType */ |
||
| 204 | foreach ($featureTypes as $featureType) { |
||
| 205 | if ($featureType->getFeatureId() === $feature->getId()) { |
||
| 206 | $loopResultRow->set( |
||
| 207 | self::formatSlug( |
||
| 208 | $featureType->getVirtualColumn('SLUG') |
||
| 209 | ), |
||
| 210 | true |
||
| 211 | ); |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | $this->addOutputFields($loopResultRow, $feature); |
||
| 216 | |||
| 217 | $loopResult->addRow($loopResultRow); |
||
| 218 | } |
||
| 219 | |||
| 220 | return $loopResult; |
||
| 221 | } |
||
| 222 | } |
||
| 223 |