Conditions | 14 |
Paths | 810 |
Total Lines | 47 |
Code Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
120 | public function changeBillingFields(array $jsLayout): array |
||
121 | { |
||
122 | // phpcs:ignore |
||
123 | foreach ($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'] as &$payment) { |
||
124 | if (isset($payment['children']['form-fields'])) { |
||
125 | $billingFields = &$payment['children']['form-fields']['children']; |
||
126 | if ($this->config->isEnabledClasses()) { |
||
127 | $billingFields = $this->addtionalClasses->setAddtionalClasses($billingFields); |
||
128 | } |
||
129 | if ($this->config->isEnabledAutocomplete()) { |
||
130 | $billingFields = $this->autocomplete->setAutocomplete($billingFields); |
||
131 | } |
||
132 | if ($this->config->isEnabledPlaceholder()) { |
||
133 | $billingFields = $this->placeholder->setPlaceholder($billingFields); |
||
134 | } |
||
135 | } |
||
136 | } |
||
137 | // phpcs:ignore |
||
138 | if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'])) { |
||
139 | // phpcs:ignore |
||
140 | $billingAddressOnPage = &$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children']; |
||
141 | if ($this->config->isEnabledClasses()) { |
||
142 | $billingAddressOnPage = $this->addtionalClasses->setAddtionalClasses($billingAddressOnPage); |
||
143 | } |
||
144 | if ($this->config->isEnabledAutocomplete()) { |
||
145 | $billingAddressOnPage = $this->autocomplete->setAutocomplete($billingAddressOnPage); |
||
146 | } |
||
147 | if ($this->config->isEnabledPlaceholder()) { |
||
148 | $billingAddressOnPage = $this->placeholder->setPlaceholder($billingAddressOnPage); |
||
149 | } |
||
150 | } |
||
151 | // phpcs:ignore |
||
152 | if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form'])) { |
||
153 | // phpcs:ignore |
||
154 | $billingAddressOnPage = &$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['beforeMethods']['children']['billing-address-form']['children']['form-fields']['children']; |
||
155 | if ($this->config->isEnabledClasses()) { |
||
156 | $billingAddressOnPage = $this->addtionalClasses->setAddtionalClasses($billingAddressOnPage); |
||
157 | } |
||
158 | if ($this->config->isEnabledAutocomplete()) { |
||
159 | $billingAddressOnPage = $this->autocomplete->setAutocomplete($billingAddressOnPage); |
||
160 | } |
||
161 | if ($this->config->isEnabledPlaceholder()) { |
||
162 | $billingAddressOnPage = $this->placeholder->setPlaceholder($billingAddressOnPage); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | return $jsLayout; |
||
167 | } |
||
190 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.