| Conditions | 9 |
| Paths | 16 |
| Total Lines | 54 |
| Code Lines | 37 |
| Lines | 45 |
| Ratio | 83.33 % |
| 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 |
||
| 58 | public function down() |
||
| 59 | { |
||
| 60 | $fileName = Yii::getAlias('@app/config/web-configurables.php'); |
||
| 61 | View Code Duplication | if (true === is_file($fileName)) { |
|
| 62 | $array = include_once($fileName); |
||
| 63 | if (true === is_array($array) && |
||
| 64 | null !== $productsFilteringMode = ArrayHelper::getValue($array, |
||
| 65 | 'modules.shop.productsFilteringMode', null) |
||
| 66 | ) { |
||
| 67 | unset($array['modules']['shop']['productsFilteringMode']); |
||
| 68 | $array['modules']['shop']['filterOnlyByParentProduct'] = |
||
| 69 | $productsFilteringMode !== ConfigConfigurationModel::FILTER_CHILDREN_ONLY ? |
||
| 70 | true : |
||
| 71 | false; |
||
| 72 | |||
| 73 | $writer = new \app\modules\config\helpers\ApplicationConfigWriter([ |
||
| 74 | 'filename' => '@app/config/web-configurables.php', |
||
| 75 | 'loadExistingConfiguration' => false, |
||
| 76 | ]); |
||
| 77 | $writer->addValues($array); |
||
| 78 | $writer->commit(); |
||
| 79 | |||
| 80 | } else { |
||
| 81 | echo "file @app/config/web-configurables.php cannot be revert. \n"; |
||
| 82 | } |
||
| 83 | } |
||
| 84 | |||
| 85 | |||
| 86 | $shopFilename = Yii::getAlias('@app/config/configurables-state/shop.php'); |
||
| 87 | View Code Duplication | if (true === file_exists($shopFilename)) { |
|
| 88 | $shopConfigurablesArray = include($shopFilename); |
||
| 89 | if (true === is_array($shopConfigurablesArray) && |
||
| 90 | null !== $productsFilteringMode = ArrayHelper::getValue($shopConfigurablesArray, |
||
| 91 | 'productsFilteringMode', null) |
||
| 92 | ) { |
||
| 93 | unset($shopConfigurablesArray['productsFilteringMode']); |
||
| 94 | $shopConfigurablesArray['filterOnlyByParentProduct'] = |
||
| 95 | $productsFilteringMode !== ConfigConfigurationModel::FILTER_CHILDREN_ONLY ? |
||
| 96 | true : |
||
| 97 | false; |
||
| 98 | |||
| 99 | $writer = new \app\modules\config\helpers\ApplicationConfigWriter([ |
||
| 100 | 'filename' => '@app/config/configurables-state/shop.php', |
||
| 101 | 'loadExistingConfiguration' => false, |
||
| 102 | ]); |
||
| 103 | $writer->addValues($shopConfigurablesArray); |
||
| 104 | $writer->commit(); |
||
| 105 | } else { |
||
| 106 | echo "file @app/config/configurables-state/shop.php cannot be revert. \n"; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | |||
| 111 | } |
||
| 112 | } |
||
| 113 |