Conditions | 4 |
Paths | 8 |
Total Lines | 51 |
Code Lines | 30 |
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 |
||
31 | public function __construct(RequestHandler $controller = null, $name = self::DEFAULT_NAME, FieldList $fields = null, FieldList $actions = null, Validator $validator = null) |
||
32 | { |
||
33 | $base_fields = FieldList::create( |
||
34 | HiddenField::create('ID'), |
||
35 | HiddenField::create('ClassName'), |
||
36 | QuantityField::create( |
||
37 | 'Quantity', |
||
38 | _t('ShoppingCart.Qty','Qty') |
||
39 | ) |
||
40 | ); |
||
41 | |||
42 | if (!empty($fields)) { |
||
43 | $base_fields->merge($fields); |
||
44 | } |
||
45 | |||
46 | $fields = $base_fields; |
||
47 | |||
48 | $base_actions = FieldList::create( |
||
49 | FormAction::create( |
||
50 | 'doAddItemToCart', |
||
51 | _t('Catalogue.AddToCart','Add to Cart') |
||
52 | )->addExtraClass('btn btn-primary') |
||
53 | ); |
||
54 | |||
55 | if (!empty($actions)) { |
||
56 | $base_actions->merge($actions); |
||
57 | } |
||
58 | |||
59 | $actions = $base_actions; |
||
60 | |||
61 | $base_validator = RequiredFields::create(["Quantity"]); |
||
62 | |||
63 | if (!empty($validator)) { |
||
64 | $base_validator->appendRequiredFields($validator); |
||
65 | } |
||
66 | |||
67 | $validator = $base_validator; |
||
68 | |||
69 | parent::__construct( |
||
70 | $controller, |
||
71 | $name, |
||
72 | $fields, |
||
73 | $actions, |
||
74 | $validator |
||
75 | ); |
||
76 | |||
77 | $this->addExtraClass("add-to-cart-form"); |
||
78 | |||
79 | $this->setTemplate("SilverCommerce\\ShoppingCart\\Forms\\Includes\\AddToCartForm"); |
||
80 | |||
81 | $this->extend("updateAddToCartForm"); |
||
82 | } |
||
210 | } |
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