Conditions | 10 |
Paths | 62 |
Total Lines | 103 |
Code Lines | 52 |
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 |
||
124 | protected function getProductFields(FieldList $fields) |
||
125 | { |
||
126 | $hiddenTitle = ($this->product->ReceiptTitle) ? |
||
127 | htmlspecialchars($this->product->ReceiptTitle) : |
||
128 | htmlspecialchars($this->product->Title); |
||
129 | $code = $this->product->Code; |
||
130 | |||
131 | if ($this->product->isAvailable()) { |
||
132 | $fields->push( |
||
133 | HiddenField::create('name') |
||
134 | ->setValue( |
||
135 | self::getGeneratedValue($code, 'name', $hiddenTitle, 'value') |
||
136 | ) |
||
137 | ); |
||
138 | |||
139 | $fields->push( |
||
140 | HiddenField::create('category') |
||
141 | ->setValue( |
||
142 | self::getGeneratedValue($code, 'category', $this->product->FoxyCategory()->Code, 'value') |
||
143 | ) |
||
144 | ); |
||
145 | |||
146 | $fields->push( |
||
147 | HiddenField::create('code') |
||
148 | ->setValue( |
||
149 | self::getGeneratedValue($code, 'code', $this->product->Code, 'value') |
||
150 | ) |
||
151 | ); |
||
152 | |||
153 | $fields->push( |
||
154 | HiddenField::create('product_id') |
||
155 | ->setValue( |
||
156 | self::getGeneratedValue($code, 'product_id', $this->product->ID, 'value') |
||
157 | ) |
||
158 | ); |
||
159 | |||
160 | $fields->push( |
||
161 | HiddenField::create('price') |
||
162 | ->setValue( |
||
163 | self::getGeneratedValue($code, 'price', $this->product->Price, 'value') |
||
164 | ) |
||
165 | ); |
||
166 | |||
167 | if ($this->product->hasExtension(Shippable::class)) { |
||
168 | if ($this->product->Weight > 0) { |
||
169 | $fields->push( |
||
170 | HiddenField::create('weight') |
||
171 | ->setValue( |
||
172 | self::getGeneratedValue($code, 'weight', $this->product->Weight, 'value') |
||
173 | ) |
||
174 | ); |
||
175 | } |
||
176 | } |
||
177 | |||
178 | $image = null; |
||
179 | if ($this->product->hasMethod('getImage')) { |
||
180 | if ($this->product->getImage()) { |
||
181 | $image = $this->product->getImage()->CMSThumbnail()->absoluteURL; |
||
182 | } |
||
183 | if ($image) { |
||
184 | $fields->push( |
||
185 | HiddenField::create('image') |
||
186 | ->setValue( |
||
187 | self::getGeneratedValue($code, 'image', $image, 'value') |
||
188 | ) |
||
189 | ); |
||
190 | } |
||
191 | } |
||
192 | |||
193 | |||
194 | /* |
||
195 | // TODO: revisit after product options are implemented |
||
196 | $optionsSet = $this->getProductOptionSet(); |
||
197 | $fields->push($optionsSet); |
||
198 | $quantityMax = ($this->site_config->MaxQuantity) ? $this->site_config->MaxQuantity : 10; |
||
199 | $fields->push(QuantityField::create('x:visibleQuantity')->setTitle('Quantity')->setValue(1)); |
||
200 | $fields->push( |
||
201 | HiddenField::create('quantity') |
||
202 | ->setValue( |
||
203 | self::getGeneratedValue($code, 'quantity', 1, 'value') |
||
204 | ) |
||
205 | ); |
||
206 | */ |
||
207 | |||
208 | $fields->push( |
||
209 | HeaderField::create('submitPrice', '$' . $this->product->Price, 4) |
||
210 | ->addExtraClass('submit-price') |
||
211 | ); |
||
212 | $fields->push( |
||
213 | $unavailable = HeaderField::create('unavailableText', 'Selection unavailable', 4) |
||
214 | ->addExtraClass('unavailable-text') |
||
215 | ); |
||
216 | if (!empty(trim($this->foxy_setting->StoreDomain)) && $this->product->isAvailable()) { |
||
217 | $unavailable->addExtraClass('hidden'); |
||
218 | } |
||
219 | |||
220 | } else { |
||
221 | $fields->push(HeaderField::create('unavailableText', 'currently unavaiable', 4)); |
||
222 | } |
||
223 | |||
224 | $this->extend('updateProductFields', $fields); |
||
225 | |||
226 | return $fields; |
||
227 | } |
||
277 |
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