Conditions | 14 |
Paths | 8 |
Total Lines | 78 |
Code Lines | 58 |
Lines | 0 |
Ratio | 0 % |
Changes | 17 | ||
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 |
||
169 | public function updateFormWithQuicklinks($form) |
||
170 | { |
||
171 | $shortcuts = $this->getLinksFromImplementor(); |
||
172 | // print_r($shortcuts); |
||
173 | $html = ''; |
||
174 | $max = $this->Config()->get('max_shortcuts_per_group'); |
||
175 | if (count($shortcuts)) { |
||
176 | $html = '<div class="grid-wrapper">'; |
||
177 | |||
178 | usort( |
||
179 | $shortcuts, |
||
180 | function ($a, $b) { |
||
181 | ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0); |
||
182 | } |
||
183 | ); |
||
184 | |||
185 | foreach ($shortcuts as $groupCode => $groupDetails) { |
||
186 | $colour = ''; |
||
187 | if (!empty($groupDetails['Colour'])) { |
||
188 | $colour = 'style="background-color: ' . $groupDetails['Colour'] . '"'; |
||
189 | } |
||
190 | $icon = ''; |
||
191 | if (!empty($groupDetails['IconClass'])) { |
||
192 | $icon = '<i class="' . $groupDetails['IconClass'] . '"></i> '; |
||
193 | } |
||
194 | $html .= ' |
||
195 | <div class="grid-cell" ' . $colour . '> |
||
196 | <div class="header"> |
||
197 | <h1>' . $icon . '' . ($groupDetails['Title'] ?? $groupCode) . '</h1> |
||
198 | </div> |
||
199 | <div class="entries">'; |
||
200 | $items = $groupDetails['Items'] ?? []; |
||
201 | if (!empty($entry['Link']) && class_exists($entry['Link'])) { |
||
202 | $obj = Injector::inst()->get($entry['Link']); |
||
203 | if ($obj instanceof DataObject) { |
||
204 | $entry['Link'] = DataObject::get_one($entry['Link'])->CMSEditLink(); |
||
205 | } else { |
||
206 | $entry['Link'] = $obj->Link(); |
||
207 | } |
||
208 | } |
||
209 | foreach ($items as $count => $entry) { |
||
210 | $entry['Class'] = $entry['Class'] ?? ''; |
||
211 | $entry['Class'] .= ($count > $max) ? ' more-item' : ''; |
||
212 | $html .= $this->makeShortCut( |
||
213 | (string) $entry['Title'], |
||
214 | (string) $entry['Link'], |
||
215 | $entry['OnClick'] ?? '', |
||
216 | $entry['Script'] ?? '', |
||
217 | $entry['Class'] ?? '', |
||
218 | $entry['IconClass'] ?? '', |
||
219 | $entry['Target'] ?? '', |
||
220 | )->Field(); |
||
221 | if($count > $max && count($items) == $count + 1) { |
||
222 | $html .= $this->makeShortCut( |
||
223 | $this->Config()->get('more_phrase'), |
||
224 | '#', // link |
||
225 | 'dashboardWelcomeQuickLinksSetupInputAndFilterToggleMore(event); return false;', // onclick |
||
226 | '', // script |
||
227 | 'more-item-more', //class |
||
228 | )->Field(); |
||
229 | } |
||
230 | } |
||
231 | $html .= '</div></div>'; |
||
232 | } |
||
233 | } |
||
234 | $kc = (array) $this->Config()->get('colour_options'); |
||
235 | if(empty($kc)) { |
||
236 | $kc = $this->Config()->get('default_colour_options'); |
||
237 | } |
||
238 | $kcCount = count($kc); |
||
239 | $colours = ''; |
||
240 | foreach ($kc as $key => $colour) { |
||
241 | $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: '.$this->getFontColor($colour).'!important;}'; |
||
242 | } |
||
243 | $html .= '</div>'; |
||
244 | $html .= '<script>window.setTimeout(dashboardWelcomeQuickLinksSetupInputAndFilter, 500)</script>'; |
||
245 | $html .= '<style>' . $colours . '</style>'; |
||
246 | $form->Fields()->push(LiteralField::create('ShortCuts', $html)); |
||
247 | } |
||
343 |
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