Passed
Push — master ( ab49c9...f82b12 )
by Nicolaas
03:45
created
src/Api/SearchApi.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 
113 113
     public function setQuickSearchType(string $nameOrType): SearchApi
114 114
     {
115
-        if($nameOrType === 'all') {
115
+        if ($nameOrType === 'all') {
116 116
             $this->isQuickSearch = false;
117 117
             $this->quickSearchType = '';
118
-        } elseif($nameOrType === 'limited') {
118
+        } elseif ($nameOrType === 'limited') {
119 119
             $this->isQuickSearch = true;
120 120
             $this->quickSearchType = '';
121
-        } elseif(class_exists($nameOrType)) {
121
+        } elseif (class_exists($nameOrType)) {
122 122
             $this->quickSearchType = $nameOrType;
123 123
             $object = Injector::inst()->get($nameOrType);
124 124
             $this->setIncludedClasses($object->getClassesToSearch());
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
     public function setBaseClass(string $class): SearchApi
151 151
     {
152
-        if(class_exists($class)) {
152
+        if (class_exists($class)) {
153 153
             $this->baseClass = $class;
154 154
         }
155 155
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
     public function buildCache(?string $word = ''): SearchApi
226 226
     {
227
-        if($this->cacheHasBeenBuilt !== $word) {
227
+        if ($this->cacheHasBeenBuilt !== $word) {
228 228
             $this->getLinksInner($word);
229 229
             $this->cacheHasBeenBuilt = $word;
230 230
         }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
     public function doReplacement(string $word, string $replace): int
256 256
     {
257 257
         $count = 0;
258
-        if($word) {
258
+        if ($word) {
259 259
             $this->buildCache($word);
260 260
             $replace = $this->securityCheckInput($replace);
261 261
             foreach ($this->objects as $item) {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
                 if ($item->canEdit()) {
264 264
                     $fields = $this->getAllValidFields($className);
265 265
                     foreach ($fields as $field) {
266
-                        if(!$this->includeFieldTest($className, $field)) {
266
+                        if (!$this->includeFieldTest($className, $field)) {
267 267
                             continue;
268 268
                         }
269 269
                         $new = str_replace($word, $replace, $item->{$field});
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
         $this->workOutInclusionsAndExclusions();
329 329
 
330 330
         // important to do this first
331
-        if($word) {
331
+        if ($word) {
332 332
             $this->setWordsAsString($word);
333 333
         }
334 334
         $this->workOutWordsForSearching();
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         if (count($this->words)) {
342 342
             foreach ($this->getAllDataObjects() as $className) {
343 343
 
344
-                if(!$this->includeClassTest($className)) {
344
+                if (!$this->includeClassTest($className)) {
345 345
                     continue;
346 346
                 }
347 347
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                 $fields = $this->getAllValidFields($className);
350 350
                 $filterAny = [];
351 351
                 foreach ($fields as $field) {
352
-                    if(!$this->includeFieldTest($className, $field)) {
352
+                    if (!$this->includeFieldTest($className, $field)) {
353 353
                         continue;
354 354
                     }
355 355
                     $filterAny[$field . ':PartialMatch'] = $this->words;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                         DB::alteration_message(' ... Filter: ' . implode(', ', array_keys($filterAny)));
364 364
                     }
365 365
                     $defaultList = $this->getDefaultList($className);
366
-                    if(empty($defaultList)) {
366
+                    if (empty($defaultList)) {
367 367
                         $array[$className] = $className::get();
368 368
                     }
369 369
                     $array[$className] = $array[$className]->filter(['ClassName' => $className]);
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
         $array = [];
407 407
         $classNames = $this->getAllDataObjects();
408 408
         foreach ($classNames as $className) {
409
-            if($this->includeClassTest($className)) {
409
+            if ($this->includeClassTest($className)) {
410 410
                 $array[$className] = $className::get()
411 411
                     ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold))
412 412
                     ->sort(['LastEdited' => 'DESC'])
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                         ->limit($limit)
455 455
                     ;
456 456
                     foreach ($items as $item) {
457
-                        if(isset($fullListCheck[$item->ClassName][$item->ID])) {
457
+                        if (isset($fullListCheck[$item->ClassName][$item->ID])) {
458 458
                             continue;
459 459
                         }
460 460
                         if ($item->canView()) {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
         $items = $this->turnArrayIntoObjects($matches);
489 489
         foreach ($items as $item) {
490
-            if($item->canView()) {
490
+            if ($item->canView()) {
491 491
                 $link = $finder->getLink($item, $this->excludedClasses);
492 492
                 $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : '';
493 493
                 $list->push(
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         }
512 512
         $finder->saveCache();
513 513
 
514
-        if(!empty($this->sortOverride)) {
514
+        if (!empty($this->sortOverride)) {
515 515
             return $list->sort($this->sortOverride);
516 516
         } else {
517 517
             return $list->sort(['SiteWideSearchSortValue' => 'ASC']);
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
 
665 665
     protected function includeClassTest(string $className): bool
666 666
     {
667
-        if(count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) {
667
+        if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) {
668 668
             if ($this->debug) {
669 669
                 DB::alteration_message(' ... Skipping as not included ' . $className);
670 670
             }
671 671
             return false;
672 672
         }
673
-        if(count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) {
673
+        if (count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) {
674 674
             if ($this->debug) {
675 675
                 DB::alteration_message(' ... Skipping as excluded ' . $className);
676 676
             }
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 
686 686
     protected function includeFieldTest(string $className, string $field): bool
687 687
     {
688
-        if(isset($this->includedClassFieldCombos[$className][$field])) {
688
+        if (isset($this->includedClassFieldCombos[$className][$field])) {
689 689
             return true;
690
-        } elseif(count($this->includedFields)) {
690
+        } elseif (count($this->includedFields)) {
691 691
             return in_array($field, $this->includedFields, true);
692 692
         } elseif (count($this->excludedFields)) {
693 693
             return in_array($field, $this->includedFields, true) ? false : true;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
     protected function includeSubClasses(array $classes): array
700 700
     {
701 701
         $toAdd = [];
702
-        foreach($classes as $class) {
702
+        foreach ($classes as $class) {
703 703
             $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false));
704 704
         }
705 705
         return array_unique(array_merge($classes, $toAdd));
Please login to merge, or discard this patch.
src/Helpers/FindEditableObjects.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
                 $rels = $dataObject->{$relationName}();
247 247
                 if ($rels) {
248 248
                     if ($rels instanceof DataList) {
249
-                        if(!$rels instanceof UnsavedRelationList) {
249
+                        if (!$rels instanceof UnsavedRelationList) {
250 250
                             $rels = $rels->first();
251 251
                         }
252 252
                     }
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
      */
302 302
     protected function classCanBeIncluded(string $dataObjectClassName): bool
303 303
     {
304
-        if(count($this->excludedClasses)) {
305
-            if(!class_exists($dataObjectClassName)) {
304
+        if (count($this->excludedClasses)) {
305
+            if (!class_exists($dataObjectClassName)) {
306 306
                 return false;
307 307
             }
308 308
             return !in_array($dataObjectClassName, $this->excludedClasses, true);
Please login to merge, or discard this patch.