Passed
Push — master ( e8ea42...382c9c )
by Nicolaas
03:44
created
src/Admin/SearchAdmin.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
                 _t(__CLASS__ . '.ReplaceToggle', 'Replace with ... (optional - make a backup first!)'),
91 91
                 [
92 92
                     (new CheckboxField('ApplyReplace', 'Run replace (please make sure to make a backup first!)', $this->applyReplace))
93
-                      ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'),
93
+                        ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'),
94 94
                     (new TextField('ReplaceWith', 'Replace (optional - careful!)', $this->replace ?? ''))
95 95
                         ->setAttribute('placeholder', 'e.g. contract - make sure to also tick checkbox below'),
96 96
                 ]
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 
57 57
     protected function init()
58 58
     {
59
-        if($this->request->param('Action')) {
60
-            if(empty($this->request->postVars())) {
59
+        if ($this->request->param('Action')) {
60
+            if (empty($this->request->postVars())) {
61 61
                 $this->redirect('/admin/find');
62 62
             }
63 63
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         if (!$this->getRequest()->requestVar('Keywords')) {
112 112
             $lastResults = $this->lastSearchResults();
113
-            if($lastResults) {
113
+            if ($lastResults) {
114 114
                 $resultsTitle = 'Last Results';
115 115
             } else {
116 116
                 $resultsTitle = 'Last Edited';
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
         Environment::increaseTimeLimitTo(300);
181 181
         Environment::setMemoryLimitMax(-1);
182 182
         Environment::increaseMemoryLimitTo(-1);
183
-        if(empty($this->rawData)) {
183
+        if (empty($this->rawData)) {
184 184
             $lastResults = $this->lastSearchResults();
185
-            if($lastResults) {
185
+            if ($lastResults) {
186 186
                 return $lastResults;
187 187
             }
188 188
         }
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
             ->setWordsAsString($this->keywords)
209 209
             ->getLinks()
210 210
         ;
211
-        if($results->count() === 1) {
211
+        if ($results->count() === 1) {
212 212
             $result = $results->first();
213 213
             $this->redirect($result->CMSEditLink);
214 214
             return null;
215 215
         }
216 216
         // Accessing the session
217 217
         $session = $this->getRequest()->getSession();
218
-        if($session) {
218
+        if ($session) {
219 219
             $session->set('QuickSearchLastResults', serialize($results->toArray()));
220 220
         }
221 221
         return $results;
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
     {
247 247
         // Accessing the session
248 248
         $session = $this->getRequest()->getSession();
249
-        if($this->quickSearchType) {
249
+        if ($this->quickSearchType) {
250 250
             $session->set('QuickSearchType', $this->quickSearchType);
251
-        } elseif($session) {
251
+        } elseif ($session) {
252 252
             $this->quickSearchType = $session->get('QuickSearchType');
253
-            if(isset($_GET['flush'])) {
253
+            if (isset($_GET['flush'])) {
254 254
                 $this->quickSearchType = '';
255 255
                 $session->set('QuickSearchType', '');
256 256
             }
257 257
         }
258
-        if(!$this->quickSearchType) {
258
+        if (!$this->quickSearchType) {
259 259
             $this->quickSearchType = $this->Config()->get('default_quick_search_type');
260 260
         }
261 261
         return (string) $this->quickSearchType;
@@ -265,15 +265,15 @@  discard block
 block discarded – undo
265 265
     {
266 266
         // Accessing the session
267 267
         $session = $this->getRequest()->getSession();
268
-        if($session) {
269
-            if(isset($_GET['flush'])) {
268
+        if ($session) {
269
+            if (isset($_GET['flush'])) {
270 270
                 $session->clear('QuickSearchLastResults');
271 271
             } else {
272 272
                 $data = $session->get('QuickSearchLastResults');
273
-                if($data) {
273
+                if ($data) {
274 274
                     $array = unserialize($data);
275 275
                     $al = ArrayList::create();
276
-                    foreach($array as $item) {
276
+                    foreach ($array as $item) {
277 277
                         $al->push($item);
278 278
                     }
279 279
                     return $al;
Please login to merge, or discard this patch.
src/QuickSearches/QuickSearchBaseClass.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,10 +52,10 @@
 block discarded – undo
52 52
             'limited' => 'Limited search',
53 53
         ];
54 54
         $availableSearchClasses = self::available_quick_searches();
55
-        if(!empty($availableSearchClasses) > 0) {
56
-            foreach($availableSearchClasses as $availableSearchClass) {
55
+        if (!empty($availableSearchClasses) > 0) {
56
+            foreach ($availableSearchClasses as $availableSearchClass) {
57 57
                 $singleton = Injector::inst()->get($availableSearchClass);
58
-                if($singleton->isEnabled()) {
58
+                if ($singleton->isEnabled()) {
59 59
                     $array[$availableSearchClass] = $singleton->getTitle();
60 60
                 }
61 61
             }
Please login to merge, or discard this patch.
src/Api/SearchApi.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 
105 105
     public function setQuickSearchType(string $nameOrType): SearchApi
106 106
     {
107
-        if($nameOrType === 'all') {
107
+        if ($nameOrType === 'all') {
108 108
             $this->isQuickSearch = false;
109 109
             $this->quickSearchType = '';
110
-        } elseif($nameOrType === 'limited') {
110
+        } elseif ($nameOrType === 'limited') {
111 111
             $this->isQuickSearch = true;
112 112
             $this->quickSearchType = '';
113
-        } elseif(class_exists($nameOrType)) {
113
+        } elseif (class_exists($nameOrType)) {
114 114
             $this->quickSearchType = $nameOrType;
115 115
             $object = Injector::inst()->get($nameOrType);
116 116
             $this->setIncludedClasses($object->getClassesToSearch());
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function setBaseClass(string $class): SearchApi
142 142
     {
143
-        if(class_exists($class)) {
143
+        if (class_exists($class)) {
144 144
             $this->baseClass = $class;
145 145
         }
146 146
 
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
         $count = 0;
252 252
         // we should have these already.
253 253
         $word = $this->securityCheckInput($word);
254
-        if($word) {
254
+        if ($word) {
255 255
             // important to do this first
256 256
             foreach ($this->objects as $item) {
257 257
                 $className = $item->ClassName;
258 258
                 if ($item->canEdit()) {
259 259
                     $fields = $this->getAllValidFields($className);
260 260
                     foreach ($fields as $field) {
261
-                        if(!$this->includeField($className, $field)) {
261
+                        if (!$this->includeField($className, $field)) {
262 262
                             continue;
263 263
                         }
264 264
                         $new = str_replace($word, $replace, $item->{$field});
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         if (count($this->words)) {
336 336
             foreach ($this->getAllDataObjects() as $className) {
337 337
 
338
-                if(!$this->includeClassName($className)) {
338
+                if (!$this->includeClassName($className)) {
339 339
                     continue;
340 340
                 }
341 341
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
                 $fields = $this->getAllValidFields($className);
344 344
                 $filterAny = [];
345 345
                 foreach ($fields as $field) {
346
-                    if(!$this->includeField($className, $field)) {
346
+                    if (!$this->includeField($className, $field)) {
347 347
                         continue;
348 348
                     }
349 349
                     $filterAny[$field . ':PartialMatch'] = $this->words;
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
         $array = [];
396 396
         $classNames = $this->getAllDataObjects();
397 397
         foreach ($classNames as $className) {
398
-            if($this->includeClassName($className)) {
398
+            if ($this->includeClassName($className)) {
399 399
                 $array[$className] = $className::get()
400 400
                     ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold))
401 401
                     ->sort(['LastEdited' => 'DESC'])
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
         $items = $this->turnArrayIntoObjects($matches);
464 464
         foreach ($items as $item) {
465 465
             $link = $finder->getLink($item, $this->excludedClasses);
466
-            if($item->canView()) {
466
+            if ($item->canView()) {
467 467
                 $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : '';
468 468
                 $list->push(
469 469
                     ArrayData::create(
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
         }
486 486
         $finder->saveCache();
487 487
 
488
-        if(!empty($this->sortOverride)) {
488
+        if (!empty($this->sortOverride)) {
489 489
             return $list->sort($this->sortOverride);
490 490
         } else {
491 491
             return $list->sort(['SiteWideSearchSortValue' => 'ASC']);
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
     protected function getAllValidFields(string $className): array
632 632
     {
633 633
         $fields = $this->getCache()->getAllValidFields($className, $this->isQuickSearch, $this->includedFields);
634
-        if(isset($this->includedClassFieldCombos[$className])) {
635
-            foreach($this->includedClassFieldCombos[$className] as $name => $type) {
634
+        if (isset($this->includedClassFieldCombos[$className])) {
635
+            foreach ($this->includedClassFieldCombos[$className] as $name => $type) {
636 636
                 $fields[] = $name;
637 637
             }
638 638
         }
@@ -642,13 +642,13 @@  discard block
 block discarded – undo
642 642
 
643 643
     protected function includeClassName(string $className): bool
644 644
     {
645
-        if(count($this->excludedClasses) && in_array($className, $this->excludedClasses, true)) {
645
+        if (count($this->excludedClasses) && in_array($className, $this->excludedClasses, true)) {
646 646
             if ($this->debug) {
647 647
                 DB::alteration_message(' ... Skipping as excluded ' . $className);
648 648
             }
649 649
             return false;
650 650
         }
651
-        if(count($this->includedClasses) && !in_array($className, $this->includedClasses, true)) {
651
+        if (count($this->includedClasses) && !in_array($className, $this->includedClasses, true)) {
652 652
             if ($this->debug) {
653 653
                 DB::alteration_message(' ... Skipping as not included ' . $className);
654 654
             }
@@ -663,9 +663,9 @@  discard block
 block discarded – undo
663 663
 
664 664
     protected function includeField(string $className, string $field): bool
665 665
     {
666
-        if(isset($this->includedClassFieldCombos[$className][$field])) {
666
+        if (isset($this->includedClassFieldCombos[$className][$field])) {
667 667
             return true;
668
-        } elseif(in_array($field, $this->includedFields, true)) {
668
+        } elseif (in_array($field, $this->includedFields, true)) {
669 669
             return true;
670 670
         } elseif (!in_array($field, $this->excludedFields, true)) {
671 671
             return true;
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
     protected function includeSubClasses(array $classes): array
678 678
     {
679 679
         $toAdd = [];
680
-        foreach($classes as $class) {
680
+        foreach ($classes as $class) {
681 681
             $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false));
682 682
         }
683 683
         return array_unique(array_merge($classes, $toAdd));
Please login to merge, or discard this patch.
src/Helpers/FindEditableObjects.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -311,8 +311,8 @@
 block discarded – undo
311 311
      */
312 312
     protected function classCanBeIncluded(string $dataObjectClassName): bool
313 313
     {
314
-        if(count($this->excludedClasses) || count($this->includedClasses)) {
315
-            if(!class_exists($dataObjectClassName)) {
314
+        if (count($this->excludedClasses) || count($this->includedClasses)) {
315
+            if (!class_exists($dataObjectClassName)) {
316 316
                 return false;
317 317
             }
318 318
             if (count($this->includedClasses)) {
Please login to merge, or discard this patch.
src/Helpers/FindClassesAndFields.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
     public static function inst(string $baseClass)
89 89
     {
90
-        if(self::$singleton === null) {
90
+        if (self::$singleton === null) {
91 91
             self::$singleton = Injector::inst()->get(static::class);
92 92
         }
93 93
         self::$singleton->setBaseClass($baseClass);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         foreach ($this->cache['AllValidFields'][$className] as $name => $type) {
129 129
             if ($this->isValidFieldType($type, $className, $name)) {
130 130
                 $array[] = $name;
131
-            } elseif(in_array($name, $includedFields, true)) {
131
+            } elseif (in_array($name, $includedFields, true)) {
132 132
                 $array[] = $name;
133 133
             }
134 134
         }
Please login to merge, or discard this patch.