Conditions | 4 |
Paths | 2 |
Total Lines | 68 |
Code Lines | 40 |
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 |
||
125 | public function parameterFields() |
||
126 | { |
||
127 | $fields = new FieldList(); |
||
128 | |||
129 | $first_order = Invoice::get() |
||
130 | ->sort('Created', 'ASC') |
||
131 | ->first(); |
||
132 | |||
133 | // Check if any order exist |
||
134 | if ($first_order) { |
||
135 | // List all months |
||
136 | $months = array('All'); |
||
137 | for ($i = 1; $i <= 12; $i++) { |
||
138 | $months[] = date("F", mktime(0, 0, 0, $i + 1, 0, 0)); |
||
139 | } |
||
140 | |||
141 | // Get the first order, then count down from current year to that |
||
142 | $firstyear = new SSDatetime('FirstDate'); |
||
143 | $firstyear->setValue($first_order->Created); |
||
144 | $years = array(); |
||
145 | for ($i = date('Y'); $i >= $firstyear->Year(); $i--) { |
||
146 | $years[$i] = $i; |
||
147 | } |
||
148 | |||
149 | // Order Status |
||
150 | $statuses = Invoice::config()->statuses; |
||
151 | array_unshift($statuses, 'All'); |
||
152 | |||
153 | $fields->push(TextField::create( |
||
154 | 'Filter_FirstName', |
||
155 | 'Customer First Name' |
||
156 | )); |
||
157 | |||
158 | $fields->push(TextField::create( |
||
159 | 'Filter_Surname', |
||
160 | 'Customer Surname' |
||
161 | )); |
||
162 | |||
163 | $fields->push(TextField::create( |
||
164 | 'Filter_StockID', |
||
165 | 'Stock ID' |
||
166 | )); |
||
167 | |||
168 | $fields->push(TextField::create( |
||
169 | 'Filter_ProductName', |
||
170 | 'Product Name' |
||
171 | )); |
||
172 | |||
173 | $fields->push(DropdownField::create( |
||
174 | 'Filter_Month', |
||
175 | 'Month', |
||
176 | $months |
||
177 | )); |
||
178 | |||
179 | $fields->push(DropdownField::create( |
||
180 | 'Filter_Year', |
||
181 | 'Year', |
||
182 | $years |
||
183 | )); |
||
184 | |||
185 | $fields->push(DropdownField::create( |
||
186 | 'Filter_Status', |
||
187 | 'Order Status', |
||
188 | $statuses |
||
189 | )); |
||
190 | } |
||
191 | |||
192 | return $fields; |
||
193 | } |
||
215 |
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