| Conditions | 11 |
| Paths | 242 |
| Total Lines | 108 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 144 | protected function getProductFields(FieldList $fields) |
||
| 145 | { |
||
| 146 | $hiddenTitle = ($this->product->ReceiptTitle) ? |
||
| 147 | htmlspecialchars($this->product->ReceiptTitle) : |
||
| 148 | htmlspecialchars($this->product->Title); |
||
| 149 | $code = $this->product->Code; |
||
| 150 | |||
| 151 | if ($this->product->isAvailable()) { |
||
| 152 | $fields->push( |
||
| 153 | HiddenField::create('name') |
||
| 154 | ->setValue( |
||
| 155 | self::getGeneratedValue($code, 'name', $hiddenTitle, 'value') |
||
| 156 | ) |
||
| 157 | ); |
||
| 158 | |||
| 159 | $fields->push( |
||
| 160 | HiddenField::create('category') |
||
| 161 | ->setValue( |
||
| 162 | self::getGeneratedValue($code, 'category', $this->product->FoxyCategory()->Code, 'value') |
||
| 163 | ) |
||
| 164 | ); |
||
| 165 | |||
| 166 | $fields->push( |
||
| 167 | HiddenField::create('code') |
||
| 168 | ->setValue( |
||
| 169 | self::getGeneratedValue($code, 'code', $this->product->Code, 'value') |
||
| 170 | ) |
||
| 171 | ); |
||
| 172 | |||
| 173 | $fields->push( |
||
| 174 | HiddenField::create('product_id') |
||
| 175 | ->setValue( |
||
| 176 | self::getGeneratedValue($code, 'product_id', $this->product->ID, 'value') |
||
| 177 | ) |
||
| 178 | ->setName('h:product_id') |
||
| 179 | ); |
||
| 180 | |||
| 181 | $fields->push( |
||
| 182 | HiddenField::create('price') |
||
| 183 | ->setValue( |
||
| 184 | self::getGeneratedValue($code, 'price', $this->product->Price, 'value') |
||
| 185 | ) |
||
| 186 | ); |
||
| 187 | |||
| 188 | if ($this->product->hasMethod('AbsoluteLink')) { |
||
| 189 | $fields->push( |
||
| 190 | HiddenField::create('url') |
||
| 191 | ->setValue( |
||
| 192 | self::getGeneratedValue($code, 'url', $this->product->AbsoluteLink(), 'value') |
||
| 193 | ) |
||
| 194 | ); |
||
| 195 | } |
||
| 196 | |||
| 197 | if ($this->product->hasExtension(Shippable::class)) { |
||
| 198 | if ($this->product->Weight > 0) { |
||
| 199 | $fields->push( |
||
| 200 | HiddenField::create('weight') |
||
| 201 | ->setValue( |
||
| 202 | self::getGeneratedValue($code, 'weight', $this->product->Weight, 'value') |
||
| 203 | ) |
||
| 204 | ); |
||
| 205 | } |
||
| 206 | } |
||
| 207 | |||
| 208 | $image = null; |
||
| 209 | if ($this->product->hasMethod('getImage')) { |
||
| 210 | if ($this->product->getImage()) { |
||
| 211 | $image = $this->product->getImage()->CMSThumbnail()->absoluteURL; |
||
| 212 | } |
||
| 213 | if ($image) { |
||
| 214 | $fields->push( |
||
| 215 | HiddenField::create('image') |
||
| 216 | ->setValue( |
||
| 217 | self::getGeneratedValue($code, 'image', $image, 'value') |
||
| 218 | ) |
||
| 219 | ); |
||
| 220 | } |
||
| 221 | } |
||
| 222 | |||
| 223 | if ($this->product->QuantityMax > 0) { |
||
| 224 | $fields->push( |
||
| 225 | HiddenField::create('quantity_max') |
||
| 226 | ->setValue(self::getGeneratedValue($code, 'quantity_max', $this->product->QuantityMax, 'value')) |
||
| 227 | ); |
||
| 228 | } |
||
| 229 | |||
| 230 | $fields->push($this->getProductVariations()); |
||
| 231 | |||
| 232 | |||
| 233 | if ($this->product->QuantityMax != 1) { |
||
| 234 | $fields->push(QuantityField::create('x:visibleQuantity')->setTitle('Quantity')->setValue(1)); |
||
| 235 | } |
||
| 236 | $fields->push( |
||
| 237 | HiddenField::create('quantity') |
||
| 238 | ->setValue( |
||
| 239 | self::getGeneratedValue($code, 'quantity', 1, 'value') |
||
| 240 | ) |
||
| 241 | ); |
||
| 242 | |||
| 243 | $fields->push( |
||
| 244 | HeaderField::create('submitPrice', '$' . $this->product->Price, 4) |
||
| 245 | ->addExtraClass('submit-price') |
||
| 246 | ); |
||
| 247 | } |
||
| 248 | |||
| 249 | $this->extend('updateProductFields', $fields); |
||
| 250 | |||
| 251 | return $fields; |
||
| 252 | } |
||
| 361 |
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