| Conditions | 10 |
| Paths | 4 |
| Total Lines | 112 |
| 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 |
||
| 71 | public function updateFormWithQuicklinks($form) |
||
| 72 | { |
||
| 73 | $shortcuts = $this->getLinksFromImplementor(); |
||
| 74 | $html = ''; |
||
| 75 | if (count($shortcuts)) { |
||
| 76 | $html = '<div class="grid-wrapper">'; |
||
| 77 | |||
| 78 | usort( |
||
| 79 | $shortcuts, |
||
| 80 | function ($a, $b) { |
||
| 81 | ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0); |
||
| 82 | } |
||
| 83 | ); |
||
| 84 | |||
| 85 | foreach ($shortcuts as $groupCode => $groupDetails) { |
||
| 86 | $colour = ''; |
||
| 87 | if (!empty($groupDetails['Colour'])) { |
||
| 88 | $colour = 'style="background-color: ' . $groupDetails['Colour'] . '"'; |
||
| 89 | } |
||
| 90 | $icon = ''; |
||
| 91 | if (!empty($groupDetails['IconClass'])) { |
||
| 92 | $icon = '<i class="' . $groupDetails['IconClass'] . '"></i> '; |
||
| 93 | } |
||
| 94 | $html .= ' |
||
| 95 | <div class="grid-cell" ' . $colour . '> |
||
| 96 | <div class="header"> |
||
| 97 | <h1>' . $icon . '' . ($groupDetails['Title'] ?? $groupCode) . '</h1> |
||
| 98 | </div> |
||
| 99 | <div class="entries">'; |
||
| 100 | $items = $groupDetails['Items'] ?? []; |
||
| 101 | if (!empty($entry['Link']) && class_exists($entry['Link'])) { |
||
| 102 | $obj = Injector::inst()->get($entry['Link']); |
||
| 103 | if ($obj instanceof DataObject) { |
||
| 104 | $entry['Link'] = DataObject::get_one($entry['Link'])->CMSEditLink(); |
||
| 105 | } else { |
||
| 106 | $entry['Link'] = $obj->Link(); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | foreach ($items as $entry) { |
||
| 110 | $html .= $this->makeShortCut( |
||
| 111 | $entry['Title'], |
||
| 112 | $entry['Link'], |
||
| 113 | $entry['OnClick'] ?? '', |
||
| 114 | $entry['Script'] ?? '', |
||
| 115 | $entry['Style'] ?? '', |
||
| 116 | $entry['IconClass'] ?? '', |
||
| 117 | $entry['Target'] ?? '', |
||
| 118 | )->Field(); |
||
| 119 | } |
||
| 120 | $html .= '</div></div>'; |
||
| 121 | } |
||
| 122 | } |
||
| 123 | $kc = $this->Config()->get('colour_options'); |
||
| 124 | $kcCount = count($kc); |
||
| 125 | $colours = ''; |
||
| 126 | foreach ($kc as $key => $colour) { |
||
| 127 | $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: '.$this->getFontColor($colour).'!important;}'; |
||
| 128 | } |
||
| 129 | $html .= '</div>'; |
||
| 130 | $html .= '<style> |
||
| 131 | |||
| 132 | .grid-wrapper { |
||
| 133 | display: grid; |
||
| 134 | grid-template-columns: repeat( auto-fit, minmax(300px, 1fr) );; |
||
| 135 | grid-gap: 20px; |
||
| 136 | } |
||
| 137 | |||
| 138 | .grid-wrapper .grid-cell { |
||
| 139 | max-width: 500px; |
||
| 140 | font-size: 150%; |
||
| 141 | border-radius: 1rem; |
||
| 142 | border: 1px solid #004e7f55; |
||
| 143 | display: flex; |
||
| 144 | flex-direction: column; |
||
| 145 | overflow: hidden; |
||
| 146 | box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); |
||
| 147 | transition: all 0.3s ease; |
||
| 148 | opacity: 0.8; |
||
| 149 | &:hover { |
||
| 150 | transform: scale(1.05); |
||
| 151 | box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); |
||
| 152 | opacity: 1; |
||
| 153 | } |
||
| 154 | } |
||
| 155 | .grid-wrapper .grid-cell > div { |
||
| 156 | padding: 20px; |
||
| 157 | } |
||
| 158 | .grid-wrapper .grid-cell > div.header { |
||
| 159 | padding-bottom: 0; |
||
| 160 | border-bottom: 1px solid #004e7f55; |
||
| 161 | } |
||
| 162 | .grid-wrapper .grid-cell > div.header h1 { |
||
| 163 | font-weight: 700; |
||
| 164 | font-size: 1.3rem!important; |
||
| 165 | } |
||
| 166 | .grid-wrapper .grid-cell > div.entries { |
||
| 167 | background-color: #fff; |
||
| 168 | height: 100%; |
||
| 169 | } |
||
| 170 | ' . $colours . ' |
||
| 171 | .grid-wrapper .grid-cell div.entries *, |
||
| 172 | .grid-wrapper .grid-cell div.entries a:link, |
||
| 173 | .grid-wrapper .grid-cell div.entries a:visited { |
||
| 174 | color: #222; |
||
| 175 | } |
||
| 176 | .grid-wrapper .grid-cell div.entries a:link:hover, |
||
| 177 | .grid-wrapper .grid-cell div.entries a:visited:hover { |
||
| 178 | color: #0071c4; |
||
| 179 | text-decoration: none; |
||
| 180 | } |
||
| 181 | </style>'; |
||
| 182 | $form->Fields()->push(LiteralField::create('ShortCuts', $html)); |
||
| 183 | } |
||
| 282 |
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