| Conditions | 8 |
| Paths | 14 |
| Total Lines | 59 |
| 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 |
||
| 96 | public function parseResults(LoopResult $loopResult) |
||
| 97 | { |
||
| 98 | $featuresMeta = self::getFeaturesMeta($loopResult); |
||
| 99 | |||
| 100 | $slugs = array(); |
||
| 101 | |||
| 102 | /** @var FeatureTypeAvMeta $featureMeta */ |
||
| 103 | foreach ($featuresMeta as $featureMeta) { |
||
| 104 | $slugs[$featureMeta->getVirtualColumn('SLUG')] = true; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** @var FeatureProduct $featureValue */ |
||
| 108 | foreach ($loopResult->getResultDataCollection() as $featureValue) { |
||
| 109 | $loopResultRow = new LoopResultRow($featureValue); |
||
| 110 | |||
| 111 | $loopResultRow |
||
| 112 | ->set("ID", $featureValue->getId()) |
||
| 113 | ->set("PRODUCT", $featureValue->getProductId()) |
||
| 114 | ->set("FEATURE_AV_ID", $featureValue->getFeatureAvId()) |
||
| 115 | ->set("FREE_TEXT_VALUE", $featureValue->getFreeTextValue()) |
||
| 116 | ->set("IS_FREE_TEXT", is_null($featureValue->getFeatureAvId()) ? 1 : 0) |
||
| 117 | ->set("IS_FEATURE_AV", is_null($featureValue->getFeatureAvId()) ? 0 : 1) |
||
| 118 | ->set("LOCALE", $this->locale) |
||
| 119 | ->set("TITLE", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE')) |
||
| 120 | ->set("CHAPO", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_CHAPO')) |
||
| 121 | ->set("DESCRIPTION", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) |
||
| 122 | ->set("POSTSCRIPTUM", $featureValue->getVirtualColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) |
||
| 123 | ->set("POSITION", $featureValue->getPosition()) |
||
| 124 | ; |
||
| 125 | |||
| 126 | // init slug variable |
||
| 127 | foreach ($slugs as $slug => $bool) { |
||
| 128 | $loopResultRow->set( |
||
| 129 | self::formatSlug( |
||
| 130 | $slug |
||
| 131 | ), |
||
| 132 | null |
||
| 133 | ); |
||
| 134 | } |
||
| 135 | |||
| 136 | /** @var FeatureTypeAvMeta $featureMeta */ |
||
| 137 | foreach ($featuresMeta as $featureMeta) { |
||
| 138 | if ($featureMeta->getFeatureAvId() === $featureValue->getFeatureAvId()) { |
||
| 139 | $loopResultRow->set( |
||
| 140 | self::formatSlug( |
||
| 141 | $featureMeta->getVirtualColumn('SLUG') |
||
| 142 | ), |
||
| 143 | $featureMeta->getValue() |
||
| 144 | ); |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | $this->addOutputFields($loopResultRow, $featureValue); |
||
| 149 | |||
| 150 | $loopResult->addRow($loopResultRow); |
||
| 151 | } |
||
| 152 | |||
| 153 | return $loopResult; |
||
| 154 | } |
||
| 155 | } |
||
| 156 |