Passed
Push — master ( 27e0ff...8f0a74 )
by Nicolaas
07:55
created
src/Admin/DashboardWelcomeQuickLinks.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 
54 54
     public static function get_base_phrase(string $phrase): string
55 55
     {
56
-        if (! in_array($phrase, ['add', 'review', 'edit', 'more'])) {
56
+        if (!in_array($phrase, ['add', 'review', 'edit', 'more'])) {
57 57
             user_error('Phrase must be one of "add", "review", or "edit"', E_USER_ERROR);
58 58
         }
59 59
         $phrase = Config::inst()->get(static::class, $phrase . '_phrase');
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
             usort(
186 186
                 $shortcuts,
187
-                function ($a, $b) {
187
+                function($a, $b) {
188 188
                     $b['SortOrder'] ?? 0;
189 189
                     $a['SortOrder'] ?? 0;
190 190
                 }
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 
193 193
             foreach ($shortcuts as $groupCode => $groupDetails) {
194 194
                 $colour = '';
195
-                if (! empty($groupDetails['Colour'])) {
195
+                if (!empty($groupDetails['Colour'])) {
196 196
                     $colour = 'style="background-color: ' . $groupDetails['Colour'] . '"';
197 197
                 }
198 198
                 $icon = '';
199
-                if (! empty($groupDetails['IconClass'])) {
199
+                if (!empty($groupDetails['IconClass'])) {
200 200
                     $icon = '<i class="' . $groupDetails['IconClass'] . '"></i> ';
201 201
                 }
202 202
                 $html .= '
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                     </div>
207 207
                     <div class="entries">';
208 208
                 $items = $groupDetails['Items'] ?? [];
209
-                if (! empty($entry['Link']) && class_exists($entry['Link'])) {
209
+                if (!empty($entry['Link']) && class_exists($entry['Link'])) {
210 210
                     $obj = Injector::inst()->get($entry['Link']);
211 211
                     if ($obj instanceof DataObject) {
212 212
                         $entry['Link'] = DataObject::get_one($entry['Link'])->CMSEditLink();
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
         return $array;
269 269
     }
270 270
 
271
-    protected function makeShortCut(array $entry, ?bool $isInsideLink = false): LiteralField|string
271
+    protected function makeShortCut(array $entry, ?bool $isInsideLink = false): LiteralField | string
272 272
     {
273 273
         $title = (string) $entry['Title'];
274 274
         $link = (string) $entry['Link'];
@@ -291,31 +291,31 @@  discard block
 block discarded – undo
291 291
         if ($iconClass !== null && $iconClass !== '' && $iconClass !== '0') {
292 292
             $icon = '<i class="' . $iconClass . '"></i> ';
293 293
         }
294
-        if (! $target) {
294
+        if (!$target) {
295 295
             $target = '_self';
296 296
         }
297
-        if($isInsideLink) {
297
+        if ($isInsideLink) {
298 298
             $tag = 'span';
299 299
         } else {
300 300
             $tag = 'h2';
301 301
         }
302
-        if($class) {
303
-            $class = ' class="'.$class.'"';
302
+        if ($class) {
303
+            $class = ' class="' . $class . '"';
304 304
         }
305 305
         $insideLinkHTML = '';
306
-        if(!empty($insideLink)) {
307
-            $insideLink['Class'] = ($insideLink['Class'] ?? '').' inside-link';
306
+        if (!empty($insideLink)) {
307
+            $insideLink['Class'] = ($insideLink['Class'] ?? '') . ' inside-link';
308 308
             $insideLinkHTML = $this->makeShortCut($insideLink, true);
309 309
         }
310 310
         $target = ' target="' . $target . '"';
311 311
         if ($link !== '' && $link !== '0') {
312
-            $html = '' . $script . '<'.$tag.'' . $class . '>' . $icon . '<a href="' . $link . '" ' . $target . ' ' . $onclick . '>' . $title . '</a>'.$insideLinkHTML .'</'.$tag.'>';
312
+            $html = '' . $script . '<' . $tag . '' . $class . '>' . $icon . '<a href="' . $link . '" ' . $target . ' ' . $onclick . '>' . $title . '</a>' . $insideLinkHTML . '</' . $tag . '>';
313 313
         } else {
314
-            $html = '' . $script . '<'.$tag.'' . $class . '>' . $title . '' . $insideLinkHTML . '</'.$tag.'>
314
+            $html = '' . $script . '<' . $tag . '' . $class . '>' . $title . '' . $insideLinkHTML . '</' . $tag . '>
315 315
             ';
316 316
         }
317 317
         $html = preg_replace('/\s+/', ' ', $html);
318
-        if($isInsideLink) {
318
+        if ($isInsideLink) {
319 319
             return $html;
320 320
         } else {
321 321
             return LiteralField::create($name, $html);
Please login to merge, or discard this patch.
src/Api/DefaultDashboardProvider.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count();
95 95
             if ($pageCount < 1) {
96 96
                 $page = Injector::inst()->get($pageClassName);
97
-                if($page->canCreate()) {
97
+                if ($page->canCreate()) {
98 98
                     $pageTitle = $page->i18n_singular_name();
99 99
                     $pagesArray[] = [
100 100
                         'Title' => DashboardWelcomeQuicklinks::get_base_phrase('add') . ' ' . $pageTitle . ' (0)',
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
                 }
106 106
             } elseif ($pageCount === 1) {
107 107
                 $page = DataObject::get_one($pageClassName, ['ClassName' => $pageClassName]);
108
-                if($page->canEdit()) {
108
+                if ($page->canEdit()) {
109 109
                     $pageTitle = $page->i18n_singular_name();
110 110
                     $insideLink = [];
111
-                    if($page->canCreate()) {
111
+                    if ($page->canCreate()) {
112 112
                         $insideLink = [
113 113
                             'Title' => DashboardWelcomeQuicklinks::get_base_phrase('add'),
114 114
                             'Link' => 'admin/pages/add?PageType=' . $pageClassName,
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
                 }
124 124
             } else {
125 125
                 $page = Injector::inst()->get($pageClassName);
126
-                if($page->canEdit()) {
126
+                if ($page->canEdit()) {
127 127
                     $pageTitle = $page->i18n_plural_name();
128 128
                     $query = 'q[ClassName]=' . $pageClassName;
129 129
                     $link = 'admin/pages?' . $query;
130 130
                     $insideLink = [];
131
-                    if($page->canCreate()) {
131
+                    if ($page->canCreate()) {
132 132
                         $insideLink = [
133 133
                             'Title' => DashboardWelcomeQuicklinks::get_base_phrase('add'),
134 134
                             'Link' => 'admin/pages/add?PageType=' . $pageClassName,
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             }
145 145
         }
146 146
         $pagesArray = $this->sortByCountAndTitle($pagesArray);
147
-        foreach($pagesArray as $pageClassName => $pageArray) {
147
+        foreach ($pagesArray as $pageClassName => $pageArray) {
148 148
             DashboardWelcomeQuicklinks::add_link('PAGEFILTER', $pageArray['Title'], $pageArray['Link'], $pageArray['InsideLink']);
149 149
         }
150 150
 
@@ -255,12 +255,12 @@  discard block
 block discarded – undo
255 255
                             $title = $title['title'];
256 256
                             $model = $title['dataClass'] ?? $model;
257 257
                         }
258
-                        if (! class_exists($model)) {
258
+                        if (!class_exists($model)) {
259 259
                             continue;
260 260
                         }
261 261
                         $obj = Injector::inst()->get($model);
262 262
                         if ($obj && $obj->canView()) {
263
-                            if (! $groupAdded) {
263
+                            if (!$groupAdded) {
264 264
                                 DashboardWelcomeQuicklinks::add_group($groupCode, $ma->menu_title(), 100);
265 265
                                 $groupAdded = true;
266 266
                             }
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
                             $ma = ReflectionHelper::allowAccessToProperty(get_class($ma), 'modelClass');
269 269
                             $ma->modelClass = $model;
270 270
                             $list = $ma->getList();
271
-                            if (! $list) {
271
+                            if (!$list) {
272 272
                                 $list = $model::get();
273 273
                             }
274 274
                             $objectCount = $list->count();
275 275
                             if ($objectCount === 1) {
276 276
                                 $baseTable = Injector::inst()->get($model)->baseTable();
277 277
                                 $obj = DataObject::get_one($model, [$baseTable . '.ClassName' => $model]);
278
-                                if (! $obj) {
278
+                                if (!$obj) {
279 279
                                     $obj = DataObject::get_one($model);
280 280
                                 }
281 281
                                 if ($obj && $obj->hasMethod('CMSEditLink')) {
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                             $link = '';
291 291
                             if ($obj->hasMethod('CMSListLink')) {
292 292
                                 $link = $obj->CMSListLink();
293
-                            } if (! $link) {
293
+                            } if (!$link) {
294 294
                                 $link = $ma->getLinkForModelTab($model);
295 295
                             }
296 296
                             $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')');
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
     protected function sortByCountAndTitle(array $array): array
331 331
     {
332
-        usort($array, function ($a, $b) {
332
+        usort($array, function($a, $b) {
333 333
             $countComparison = $b['Count'] <=> $a['Count'];
334 334
             if ($countComparison === 0) {
335 335
                 return $a['Title'] <=> $b['Title'];
Please login to merge, or discard this patch.