| Conditions | 10 |
| Paths | 257 |
| Total Lines | 38 |
| Code Lines | 35 |
| 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 |
||
| 18 | public function configureAction() { |
||
| 19 | if (!empty($_POST['config'])) { |
||
| 20 | $config = App::$cur->ecommerce->config; |
||
| 21 | $config['view_empty_warehouse'] = empty($_POST['config']['view_empty_warehouse']) ? false : true; |
||
| 22 | $config['view_empty_image'] = empty($_POST['config']['view_empty_image']) ? false : true; |
||
| 23 | $config['sell_empty_warehouse'] = empty($_POST['config']['sell_empty_warehouse']) ? false : true; |
||
| 24 | $config['sell_over_warehouse'] = empty($_POST['config']['sell_over_warehouse']) ? false : true; |
||
| 25 | $config['notify_mail'] = $_POST['config']['notify_mail']; |
||
| 26 | $config['defaultCategoryView'] = $_POST['config']['defaultCategoryView']; |
||
| 27 | $config['defaultCurrency'] = $_POST['config']['defaultCurrency']; |
||
| 28 | $config['orderPrefix'] = $_POST['config']['orderPrefix']; |
||
| 29 | $config['show_zero_price'] = empty($_POST['config']['show_zero_price']) ? false : true; |
||
| 30 | $config['show_without_price'] = empty($_POST['config']['show_without_price']) ? false : true; |
||
| 31 | $config['filtersInLast'] = empty($_POST['config']['filtersInLast']) ? false : true; |
||
| 32 | $config['defaultNeedDelivery'] = empty($_POST['config']['defaultNeedDelivery']) ? false : true; |
||
| 33 | Config::save('module', $config, 'Ecommerce'); |
||
| 34 | Tools::redirect('/admin/ecommerce/configure', 'Настройки были изменены', 'success'); |
||
| 35 | } |
||
| 36 | $managers = [ |
||
| 37 | 'Ecommerce\Delivery', |
||
| 38 | 'Ecommerce\PayType', |
||
| 39 | 'Ecommerce\Warehouse', |
||
| 40 | 'Ecommerce\Unit', |
||
| 41 | 'Ecommerce\Card', |
||
| 42 | 'Ecommerce\Discount', |
||
| 43 | 'Ecommerce\Cart\Stage', |
||
| 44 | 'Ecommerce\Item\Type', |
||
| 45 | 'Ecommerce\Item\Option', |
||
| 46 | 'Ecommerce\Item\Offer\Option', |
||
| 47 | 'Ecommerce\Item\Offer\Price\Type', |
||
| 48 | 'Ecommerce\UserAdds\Field', |
||
| 49 | 'Ecommerce\Cart\Status', |
||
| 50 | 'Ecommerce\Delivery\Field', |
||
| 51 | 'Ecommerce\Delivery\Provider', |
||
| 52 | ]; |
||
| 53 | $this->view->setTitle('Настройки магазина'); |
||
| 54 | $this->view->page(['data' => compact('managers')]); |
||
| 55 | } |
||
| 56 | |||
| 102 | } |