Conditions | 14 |
Paths | 64 |
Total Lines | 31 |
Code Lines | 17 |
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 |
||
68 | public function sale(ArrayObject $params) |
||
69 | { |
||
70 | $options = $params->offsetExists('options') ? $params['options'] : []; |
||
71 | |||
72 | if (null !== $this->options['storeInVault'] && !isset($options['storeInVault'])) { |
||
73 | $options['storeInVault'] = $this->options['storeInVault']; |
||
74 | } |
||
75 | |||
76 | if (null !== $this->options['storeInVaultOnSuccess'] && !isset($options['storeInVaultOnSuccess'])) { |
||
77 | $options['storeInVaultOnSuccess'] = $this->options['storeInVaultOnSuccess']; |
||
78 | } |
||
79 | |||
80 | if (null !== $this->options['addBillingAddressToPaymentMethod'] && |
||
81 | !isset($options['addBillingAddressToPaymentMethod']) && |
||
82 | $params->offsetExists('billing')) { |
||
83 | $options['addBillingAddressToPaymentMethod'] = $this->options['addBillingAddressToPaymentMethod']; |
||
84 | } |
||
85 | |||
86 | if (null !== $this->options['storeShippingAddressInVault'] && |
||
87 | !isset($options['storeShippingAddressInVault']) && |
||
88 | $params->offsetExists('shipping')) { |
||
89 | $options['storeShippingAddressInVault'] = $this->options['storeShippingAddressInVault']; |
||
90 | } |
||
91 | |||
92 | $params['options'] = $options; |
||
93 | |||
94 | if (array_key_exists('merchantAccountId', $this->options) && null !== $this->options['merchantAccountId']) { |
||
95 | $params['merchantAccountId'] = $this->options['merchantAccountId']; |
||
96 | } |
||
97 | |||
98 | return Transaction::sale((array) $params); |
||
99 | } |
||
111 |