Conditions | 9 |
Paths | 62 |
Total Lines | 92 |
Code Lines | 56 |
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 |
||
126 | protected function getProductFields(FieldList $fields) |
||
127 | { |
||
128 | $hiddenTitle = ($this->product->ReceiptTitle) ? |
||
129 | htmlspecialchars($this->product->ReceiptTitle) : |
||
130 | htmlspecialchars($this->product->Title); |
||
131 | $code = $this->product->Code; |
||
132 | |||
133 | if ($this->product->isAvailable()) { |
||
134 | $fields->push( |
||
135 | HiddenField::create('name') |
||
136 | ->setValue( |
||
137 | self::getGeneratedValue($code, 'name', $hiddenTitle, 'value') |
||
138 | ) |
||
139 | ); |
||
140 | |||
141 | $fields->push( |
||
142 | HiddenField::create('category') |
||
143 | ->setValue( |
||
144 | self::getGeneratedValue($code, 'category', $this->product->FoxyCategory()->Code, 'value') |
||
145 | ) |
||
146 | ); |
||
147 | |||
148 | $fields->push( |
||
149 | HiddenField::create('code') |
||
150 | ->setValue( |
||
151 | self::getGeneratedValue($code, 'code', $this->product->Code, 'value') |
||
152 | ) |
||
153 | ); |
||
154 | |||
155 | $fields->push( |
||
156 | HiddenField::create('product_id') |
||
157 | ->setValue( |
||
158 | self::getGeneratedValue($code, 'product_id', $this->product->ID, 'value') |
||
159 | ) |
||
160 | ->setName('h:product_id') |
||
161 | ); |
||
162 | |||
163 | $fields->push( |
||
164 | HiddenField::create('price') |
||
165 | ->setValue( |
||
166 | self::getGeneratedValue($code, 'price', $this->product->Price, 'value') |
||
167 | ) |
||
168 | ); |
||
169 | |||
170 | if ($this->product->hasExtension(Shippable::class)) { |
||
171 | if ($this->product->Weight > 0) { |
||
172 | $fields->push( |
||
173 | HiddenField::create('weight') |
||
174 | ->setValue( |
||
175 | self::getGeneratedValue($code, 'weight', $this->product->Weight, 'value') |
||
176 | ) |
||
177 | ); |
||
178 | } |
||
179 | } |
||
180 | |||
181 | $image = null; |
||
182 | if ($this->product->hasMethod('getImage')) { |
||
183 | if ($this->product->getImage()) { |
||
184 | $image = $this->product->getImage()->CMSThumbnail()->absoluteURL; |
||
185 | } |
||
186 | if ($image) { |
||
187 | $fields->push( |
||
188 | HiddenField::create('image') |
||
189 | ->setValue( |
||
190 | self::getGeneratedValue($code, 'image', $image, 'value') |
||
191 | ) |
||
192 | ); |
||
193 | } |
||
194 | } |
||
195 | |||
196 | $optionsSet = $this->getProductOptionSet(); |
||
197 | $fields->push($optionsSet); |
||
198 | $quantityMax = (FoxyHelper::config()->get('max_quantity' != null)) ? |
||
199 | FoxyHelper::config()->get('MaxQuantity') : |
||
200 | 10; |
||
201 | $fields->push(QuantityField::create('x:visibleQuantity')->setTitle('Quantity')->setValue(1)); |
||
202 | $fields->push( |
||
203 | HiddenField::create('quantity') |
||
204 | ->setValue( |
||
205 | self::getGeneratedValue($code, 'quantity', 1, 'value') |
||
206 | ) |
||
207 | ); |
||
208 | |||
209 | $fields->push( |
||
210 | HeaderField::create('submitPrice', '$' . $this->product->Price, 4) |
||
211 | ->addExtraClass('submit-price') |
||
212 | ); |
||
213 | } |
||
214 | |||
215 | $this->extend('updateProductFields', $fields); |
||
216 | |||
217 | return $fields; |
||
218 | } |
||
325 |
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