| Conditions | 1 |
| Paths | 1 |
| Total Lines | 102 |
| Code Lines | 68 |
| Lines | 36 |
| Ratio | 35.29 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 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 register(Container $app) |
||
| 19 | { |
||
| 20 | $app['eccube.purchase.context'] = $app->protect(function (ItemHolderInterface $origin = null, Customer $user = null) { |
||
| 21 | return new PurchaseContext($origin, $user); |
||
| 22 | }); |
||
| 23 | |||
| 24 | $app['eccube.purchase.flow.cart.item_processors'] = function (Container $app) { |
||
| 25 | $processors = new ArrayCollection(); |
||
| 26 | $processors[] = new Processor\DisplayStatusValidator(); |
||
| 27 | $processors[] = new Processor\SaleLimitValidator(); |
||
| 28 | $processors[] = new Processor\DeliverySettingValidator($app[DeliveryRepository::class]); |
||
| 29 | $processors[] = new Processor\StockValidator(); |
||
| 30 | |||
| 31 | return $processors; |
||
| 32 | }; |
||
| 33 | |||
| 34 | $app['eccube.purchase.flow.cart.holder_processors'] = function (Container $app) { |
||
| 35 | $processors = new ArrayCollection(); |
||
| 36 | $processors[] = new Processor\PaymentProcessor($app[DeliveryRepository::class]); |
||
| 37 | $processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
||
| 38 | $processors[] = new Processor\DeliveryFeeFreeProcessor($app[BaseInfo::class]); |
||
| 39 | $processors[] = new Processor\PaymentTotalNegativeValidator(); |
||
| 40 | |||
| 41 | return $processors; |
||
| 42 | }; |
||
| 43 | |||
| 44 | $app['eccube.purchase.flow.cart'] = function (Container $app) { |
||
| 45 | $flow = new PurchaseFlow(); |
||
| 46 | $flow->setItemProcessors($app['eccube.purchase.flow.cart.item_processors']); |
||
| 47 | $flow->setItemHolderProcessors($app['eccube.purchase.flow.cart.holder_processors']); |
||
| 48 | |||
| 49 | return $flow; |
||
| 50 | }; |
||
| 51 | |||
| 52 | $app['eccube.purchase.flow.shopping.item_processors'] = function (Container $app) { |
||
| 53 | $processors = new ArrayCollection(); |
||
| 54 | $processors[] = new Processor\StockValidator(); |
||
| 55 | $processors[] = new Processor\DisplayStatusValidator(); |
||
| 56 | |||
| 57 | return $processors; |
||
| 58 | }; |
||
| 59 | |||
| 60 | View Code Duplication | $app['eccube.purchase.flow.shopping.holder_processors'] = function (Container $app) { |
|
| 61 | $processors = new ArrayCollection(); |
||
| 62 | $processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
||
| 63 | $processors[] = new Processor\DeliveryFeeProcessor($app['orm.em']); |
||
| 64 | $processors[] = new Processor\PaymentTotalNegativeValidator(); |
||
| 65 | $processors[] = new Processor\UsePointProcessor($app['orm.em'], $app[BaseInfo::class]); |
||
| 66 | $processors[] = new Processor\AddPointProcessor($app['orm.em'], $app[BaseInfo::class]); |
||
| 67 | $processors[] = new Processor\SubstractPointProcessor($app[BaseInfo::class]); |
||
| 68 | return $processors; |
||
| 69 | }; |
||
| 70 | |||
| 71 | $app['eccube.purchase.flow.shopping.purchase'] = function (Container $app) { |
||
| 72 | $processors = new ArrayCollection(); |
||
| 73 | $processors[] = new Processor\UsePointToCustomerPurchaseProcessor(); |
||
| 74 | return $processors; |
||
| 75 | }; |
||
| 76 | |||
| 77 | View Code Duplication | $app['eccube.purchase.flow.shopping'] = function (Container $app) { |
|
| 78 | $flow = new PurchaseFlow(); |
||
| 79 | $flow->setItemProcessors($app['eccube.purchase.flow.shopping.item_processors']); |
||
| 80 | $flow->setItemHolderProcessors($app['eccube.purchase.flow.shopping.holder_processors']); |
||
| 81 | $flow->setPurchaseProcessors($app['eccube.purchase.flow.shopping.purchase']); |
||
| 82 | |||
| 83 | return $flow; |
||
| 84 | }; |
||
| 85 | |||
| 86 | $app['eccube.purchase.flow.order.item_processors'] = function (Container $app) { |
||
| 87 | $processors = new ArrayCollection(); |
||
| 88 | $processors[] = new Processor\StockValidator(); |
||
| 89 | |||
| 90 | return $processors; |
||
| 91 | }; |
||
| 92 | |||
| 93 | View Code Duplication | $app['eccube.purchase.flow.order.holder_processors'] = function (Container $app) { |
|
| 94 | $processors = new ArrayCollection(); |
||
| 95 | $processors[] = new Processor\PaymentTotalLimitValidator($app['config']['max_total_fee']); |
||
| 96 | $processors[] = new Processor\UpdateDatePurchaseProcessor($app['config']); |
||
| 97 | $processors[] = new Processor\UsePointProcessor($app['orm.em'], $app[BaseInfo::class]); |
||
| 98 | $processors[] = new Processor\AddPointProcessor($app['orm.em'], $app[BaseInfo::class]); |
||
| 99 | $processors[] = new Processor\SubstractPointProcessor($app[BaseInfo::class]); |
||
| 100 | |||
| 101 | return $processors; |
||
| 102 | }; |
||
| 103 | |||
| 104 | $app['eccube.purchase.flow.order.purchase'] = function (Container $app) { |
||
| 105 | $processors = new ArrayCollection(); |
||
| 106 | $processors[] = new Processor\AdminOrderRegisterPurchaseProcessor($app); |
||
| 107 | |||
| 108 | return $processors; |
||
| 109 | }; |
||
| 110 | |||
| 111 | View Code Duplication | $app['eccube.purchase.flow.order'] = function (Container $app) { |
|
| 112 | $flow = new PurchaseFlow(); |
||
| 113 | $flow->setItemProcessors($app['eccube.purchase.flow.order.item_processors']); |
||
| 114 | $flow->setItemHolderProcessors($app['eccube.purchase.flow.order.holder_processors']); |
||
| 115 | $flow->setPurchaseProcessors($app['eccube.purchase.flow.order.purchase']); |
||
| 116 | |||
| 117 | return $flow; |
||
| 118 | }; |
||
| 119 | } |
||
| 120 | } |
||
| 121 |