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