| Conditions | 10 |
| Paths | 4 |
| Total Lines | 80 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| 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 |
||
| 46 | public function updateFormWithQuicklinks($form) |
||
| 47 | { |
||
| 48 | $shortcuts = $this->getLinksFromImplementor(); |
||
| 49 | $html = ''; |
||
| 50 | if (count($shortcuts)) { |
||
| 51 | $html = '<div class="grid-wrapper">'; |
||
| 52 | |||
| 53 | usort( |
||
| 54 | $shortcuts, |
||
| 55 | function ($a, $b) { |
||
| 56 | ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0); |
||
| 57 | } |
||
| 58 | ); |
||
| 59 | |||
| 60 | foreach ($shortcuts as $groupCode => $groupDetails) { |
||
| 61 | $colour = ''; |
||
| 62 | if (!empty($groupDetails['Colour'])) { |
||
| 63 | $colour = 'style="background-color: ' . $groupDetails['Colour'] . '"'; |
||
| 64 | } |
||
| 65 | $icon = ''; |
||
| 66 | if (!empty($groupDetails['IconClass'])) { |
||
| 67 | $icon = '<i class="' . $groupDetails['IconClass'] . '"></i> '; |
||
| 68 | } |
||
| 69 | $html .= ' |
||
| 70 | <div class="grid-cell" ' . $colour . '> |
||
| 71 | <h1>' . $icon . '' . ($groupDetails['Title'] ?? $groupCode) . '</h1>'; |
||
| 72 | $items = $groupDetails['Items'] ?? []; |
||
| 73 | if (!empty($entry['Link']) && class_exists($entry['Link'])) { |
||
| 74 | $obj = Injector::inst()->get($entry['Link']); |
||
| 75 | if ($obj instanceof DataObject) { |
||
| 76 | $entry['Link'] = DataObject::get_one($entry['Link'])->CMSEditLink(); |
||
| 77 | } else { |
||
| 78 | $entry['Link'] = $obj->Link(); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | foreach ($items as $entry) { |
||
| 82 | $html .= $this->makeShortCut( |
||
| 83 | $entry['Title'], |
||
| 84 | $entry['Link'], |
||
| 85 | $entry['OnClick'] ?? '', |
||
| 86 | $entry['Script'] ?? '', |
||
| 87 | $entry['Style'] ?? '', |
||
| 88 | $entry['IconClass'] ?? '', |
||
| 89 | $entry['Target'] ?? '', |
||
| 90 | )->Field(); |
||
| 91 | } |
||
| 92 | $html .= '</div>'; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | $kc = ['#F2F3F4', '#222222', '#F3C300', '#875692', '#F38400', '#A1CAF1', '#BE0032', '#C2B280', '#848482', '#008856', '#E68FAC', '#0067A5', '#F99379', '#604E97', '#F6A600', '#B3446C', '#DCD300', '#882D17', '#8DB600', '#654522', '#E25822', '#2B3D26']; |
||
| 96 | $kcCount = count($kc); |
||
| 97 | $colours = ''; |
||
| 98 | foreach ($kc as $key => $colour) { |
||
| 99 | $colours .= ' .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') {background-color: ' . $colour . '55;}'; |
||
| 100 | } |
||
| 101 | $html .= '</div>'; |
||
| 102 | $html .= '<style> |
||
| 103 | |||
| 104 | .grid-wrapper { |
||
| 105 | display: grid; |
||
| 106 | grid-template-columns: repeat( auto-fit, minmax(300px, 1fr) );; |
||
| 107 | grid-gap: 20px; |
||
| 108 | } |
||
| 109 | |||
| 110 | .grid-cell { |
||
| 111 | max-width: 500px; |
||
| 112 | padding: 20px; |
||
| 113 | font-size: 150%; |
||
| 114 | border-radius: 1rem; |
||
| 115 | border: 1px dashed #004e7f55; |
||
| 116 | } |
||
| 117 | ' . $colours . ' |
||
| 118 | .grid-cell * { |
||
| 119 | color: #222!important; |
||
| 120 | } |
||
| 121 | .grid-cell h1 { |
||
| 122 | border-bottom: 1px solid #777 |
||
| 123 | } |
||
| 124 | </style>'; |
||
| 125 | $form->Fields()->push(LiteralField::create('ShortCuts', $html)); |
||
| 126 | } |
||
| 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