Conditions | 9 |
Paths | 50 |
Total Lines | 99 |
Code Lines | 51 |
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 |
||
123 | protected function getProductFields(FieldList $fields) |
||
124 | { |
||
125 | $hiddenTitle = ($this->product->ReceiptTitle) ? |
||
126 | htmlspecialchars($this->product->ReceiptTitle) : |
||
127 | htmlspecialchars($this->product->Title); |
||
128 | $code = $this->product->Code; |
||
129 | |||
130 | if ($this->product->isAvailable()) { |
||
131 | $fields->push( |
||
132 | HiddenField::create('name') |
||
133 | ->setValue( |
||
134 | Foxy::getGeneratedValue($code, 'name', $hiddenTitle, 'value') |
||
135 | ) |
||
136 | ); |
||
137 | |||
138 | $fields->push( |
||
139 | HiddenField::create('category') |
||
140 | ->setValue( |
||
141 | Foxy::getGeneratedValue($code, 'category', $this->product->FoxyCategory()->Code, 'value') |
||
142 | ) |
||
143 | ); |
||
144 | |||
145 | $fields->push( |
||
146 | HiddenField::create('code') |
||
147 | ->setValue( |
||
148 | Foxy::getGeneratedValue($code, 'code', $this->product->Code, 'value') |
||
149 | ) |
||
150 | ); |
||
151 | |||
152 | $fields->push( |
||
153 | HiddenField::create('product_id') |
||
154 | ->setValue( |
||
155 | Foxy::getGeneratedValue($code, 'product_id', $this->product->ID, 'value') |
||
156 | ) |
||
157 | ); |
||
158 | |||
159 | $fields->push( |
||
160 | HiddenField::create('price') |
||
161 | ->setValue( |
||
162 | Foxy::getGeneratedValue($code, 'price', $this->product->Price, 'value') |
||
163 | ) |
||
164 | ); |
||
165 | |||
166 | if ($this->product->hasExtension(Shippable::class)) { |
||
167 | if ($this->product->Weight > 0) { |
||
168 | $fields->push( |
||
169 | HiddenField::create('weight') |
||
170 | ->setValue( |
||
171 | Foxy::getGeneratedValue($code, 'weight', $this->product->Weight, 'value') |
||
172 | ) |
||
173 | ); |
||
174 | } |
||
175 | } |
||
176 | |||
177 | $image = null; |
||
178 | if ($this->product->getImage()) { |
||
179 | $image = $this->product->getImage()->getCMSThumbnail()->absoluteURL; |
||
180 | } |
||
181 | if ($image) { |
||
182 | $fields->push( |
||
183 | HiddenField::create('image') |
||
184 | ->setValue( |
||
185 | Foxy::getGeneratedValue($code, 'image', $image, 'value') |
||
186 | ) |
||
187 | ); |
||
188 | } |
||
189 | |||
190 | /* |
||
191 | // TODO: revisit after product options are implemented |
||
192 | $optionsSet = $this->getProductOptionSet(); |
||
193 | $fields->push($optionsSet); |
||
194 | $quantityMax = ($this->site_config->MaxQuantity) ? $this->site_config->MaxQuantity : 10; |
||
195 | $fields->push(QuantityField::create('x:visibleQuantity')->setTitle('Quantity')->setValue(1)); |
||
196 | $fields->push( |
||
197 | HiddenField::create('quantity') |
||
198 | ->setValue( |
||
199 | Foxy::getGeneratedValue($code, 'quantity', 1, 'value') |
||
200 | ) |
||
201 | ); |
||
202 | */ |
||
203 | |||
204 | $fields->push( |
||
205 | HeaderField::create('submitPrice', '$' . $this->product->Price, 4) |
||
206 | ->addExtraClass('submit-price') |
||
207 | ); |
||
208 | $fields->push( |
||
209 | $unavailable = HeaderField::create('unavailableText', 'Selection unavailable', 4) |
||
210 | ->addExtraClass('unavailable-text') |
||
211 | ); |
||
212 | if (!empty(trim($this->foxy_setting->StoreDomain)) && $this->product->isAvailable()) { |
||
213 | $unavailable->addExtraClass('hidden'); |
||
214 | } |
||
215 | |||
216 | $this->extend('updateProductFields', $fields); |
||
217 | } else { |
||
218 | $fields->push(HeaderField::create('unavailableText', 'currently unavaiable', 4)); |
||
219 | } |
||
220 | |||
221 | return $fields; |
||
222 | } |
||
247 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths