Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — fix-upload-validators-in-repea... ( 0d6f3d )
by Pedro
14:44
created
src/app/Library/Validation/Rules/ValidUpload.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,23 +27,23 @@  discard block
 block discarded – undo
27 27
     {
28 28
         $entry = CrudPanelFacade::getCurrentEntry();
29 29
 
30
-        if(Str::contains($attribute, '.')) {
30
+        if (Str::contains($attribute, '.')) {
31 31
             $this->validateUploadInSubfield($attribute, $value, $fail, $entry);
32 32
             return;
33 33
         }
34 34
        
35
-        if (! array_key_exists($attribute, $this->data) && $entry) {
35
+        if (!array_key_exists($attribute, $this->data) && $entry) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $this->createValidator($attribute, $this->getFieldRules(), $value, $fail);
40 40
 
41
-        if (! empty($value) && ! empty($this->getFileRules())) {
41
+        if (!empty($value) && !empty($this->getFileRules())) {
42 42
             $this->createValidator($attribute, $this->getFileRules(), $value, $fail);
43 43
         }
44 44
     }
45 45
 
46
-    public static function field(string|array|ValidationRule|Rule $rules = []): self
46
+    public static function field(string | array | ValidationRule | Rule $rules = []): self
47 47
     {
48 48
         return parent::field($rules);
49 49
     }
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $mainField = Str::before($attribute, '.');
54 54
         $subfield = Str::afterLast($attribute, '.');
55
-        $row = (int)Str::before(Str::after($attribute, '.'), '.');
55
+        $row = (int) Str::before(Str::after($attribute, '.'), '.');
56 56
 
57 57
         $values[$mainField] = Uploader::mergeFilesAndValuesRecursive($this->data[$mainField], $this->data['_order_'.$mainField] ?? []);
58 58
 
59
-        if (! array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
59
+        if (!array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
60 60
             return;
61 61
         }
62 62
 
63 63
         $this->createValidator($subfield, $this->getFieldRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
64 64
         
65
-        if(!empty($value) && !empty($this->getFileRules())) {
65
+        if (!empty($value) && !empty($this->getFileRules())) {
66 66
             $this->createValidator($subfield, $this->getFileRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
67 67
         }
68 68
     }
Please login to merge, or discard this patch.
src/app/Library/Validation/Rules/ValidUploadMultiple.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $entry = CrudPanelFacade::getCurrentEntry() ?: null;
24 24
 
25
-        if(Str::contains($attribute, '.')) {
25
+        if (Str::contains($attribute, '.')) {
26 26
             $this->validateUploadInSubfield($attribute, $value, $fail, $entry);
27 27
             return;
28 28
         }
29 29
 
30
-        if (! $value = self::ensureValidValue($value)) {
30
+        if (!$value = self::ensureValidValue($value)) {
31 31
             $fail('Unable to determine the value type.');
32 32
 
33 33
             return;
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
     {
74 74
         $mainField = Str::before($attribute, '.');
75 75
         $subfield = Str::afterLast($attribute, '.');
76
-        $row = (int)Str::before(Str::after($attribute, '.'), '.');
76
+        $row = (int) Str::before(Str::after($attribute, '.'), '.');
77 77
 
78 78
         $values[$mainField] = Uploader::mergeFilesAndValuesRecursive($this->data[$mainField], $this->data['_order_'.$mainField] ?? []);
79 79
 
80
-        if (! array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
80
+        if (!array_key_exists($subfield, $values[$mainField][$row]) && $entry) {
81 81
             return;
82 82
         }
83 83
 
84 84
         $this->createValidator($subfield, $this->getFieldRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
85 85
 
86
-        if(!empty($value) && !empty($this->getFileRules())) {
86
+        if (!empty($value) && !empty($this->getFileRules())) {
87 87
             $this->createValidator($subfield, $this->getFileRules(), $values[$mainField][$row][$subfield] ?? null, $fail);
88 88
         }
89 89
     }
Please login to merge, or discard this patch.
src/app/Library/Uploaders/Support/Traits/HandleRepeatableUploads.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 {
15 15
     public bool $handleRepeatableFiles = false;
16 16
 
17
-    public null|string $repeatableContainerName = null;
17
+    public null | string $repeatableContainerName = null;
18 18
 
19 19
     /*******************************
20 20
      * Setters - fluently configure the uploader
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     /*******************************
32 32
      * Getters
33 33
      *******************************/
34
-    public function getRepeatableContainerName(): null|string
34
+    public function getRepeatableContainerName(): null | string
35 35
     {
36 36
         return $this->repeatableContainerName;
37 37
     }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         return $entry;
57 57
     }
58 58
 
59
-    public static function collecFilesAndValuesFromRequest(string $attribute): array|Collection
59
+    public static function collecFilesAndValuesFromRequest(string $attribute): array | Collection
60 60
     {
61 61
         $values = collect(CRUD::getRequest()->get($attribute));
62 62
         $files = collect(CRUD::getRequest()->file($attribute));
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) {
138 138
             $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader));
139 139
 
140
-            $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) {
140
+            $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) {
141 141
                 $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null;
142 142
 
143 143
                 return $item;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
         $values = $entry->{$this->getRepeatableContainerName()};
159 159
         $values = is_string($values) ? json_decode($values, true) : $values;
160
-        $values = array_map(function ($item) use ($repeatableUploaders) {
160
+        $values = array_map(function($item) use ($repeatableUploaders) {
161 161
             foreach ($repeatableUploaders as $upload) {
162 162
                 $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload);
163 163
             }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
     private function retrieveRepeatableRelationFiles(Model $entry)
174 174
     {
175
-        switch($this->getRepeatableRelationType()) {
175
+        switch ($this->getRepeatableRelationType()) {
176 176
             case 'BelongsToMany':
177 177
             case 'MorphToMany':
178 178
                 $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass();
@@ -218,12 +218,12 @@  discard block
 block discarded – undo
218 218
 
219 219
         $repeatableValues = collect($entry->{$this->getName()});
220 220
         foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) {
221
-            if (! $upload->shouldDeleteFiles()) {
221
+            if (!$upload->shouldDeleteFiles()) {
222 222
                 continue;
223 223
             }
224 224
             $values = $repeatableValues->pluck($upload->getName())->toArray();
225 225
             foreach ($values as $value) {
226
-                if (! $value) {
226
+                if (!$value) {
227 227
                     continue;
228 228
                 }
229 229
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     {
251 251
         $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? [];
252 252
 
253
-        array_walk($items, function (&$key, $value) {
253
+        array_walk($items, function(&$key, $value) {
254 254
             $requestValue = $key[$this->getName()] ?? null;
255 255
             $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue;
256 256
         });
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $previousValues = json_decode($entry->getOriginal($uploader->getRepeatableContainerName()), true);
264 264
 
265
-        if (! empty($previousValues)) {
265
+        if (!empty($previousValues)) {
266 266
             $previousValues = array_column($previousValues, $uploader->getName());
267 267
         }
268 268
 
269 269
         return $previousValues ?? [];
270 270
     }
271 271
 
272
-    private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $upload)
272
+    private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $upload)
273 273
     {
274 274
         $uploadedValues = $item[$upload->getName()] ?? null;
275 275
         if (is_array($uploadedValues)) {
276
-            return array_map(function ($value) use ($upload) {
276
+            return array_map(function($value) use ($upload) {
277 277
                 return Str::after($value, $upload->getPath());
278 278
             }, $uploadedValues);
279 279
         }
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
     {
293 293
         if (in_array($this->getRepeatableRelationType(), ['BelongsToMany', 'MorphToMany'])) {
294 294
             $pivotAttributes = $entry->getAttributes();
295
-            $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) {
295
+            $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) {
296 296
                 $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes));
297 297
 
298 298
                 return $itemPivotAttributes === $pivotAttributes;
299 299
             })->first();
300 300
 
301
-            if (! $connectedPivot) {
301
+            if (!$connectedPivot) {
302 302
                 return;
303 303
             }
304 304
 
305 305
             $files = $connectedPivot->getOriginal()['pivot_'.$this->getAttributeName()];
306 306
 
307
-            if (! $files) {
307
+            if (!$files) {
308 308
                 return;
309 309
             }
310 310
 
Please login to merge, or discard this patch.
src/app/Library/Uploaders/Uploader.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     private bool $deleteWhenEntryIsDeleted = true;
28 28
 
29
-    private bool|string $attachedToFakeField = false;
29
+    private bool | string $attachedToFakeField = false;
30 30
 
31 31
     /**
32 32
      * Cloud disks have the ability to generate temporary URLs to files, should we do it?
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     /*******************************
64 64
      * Static methods
65 65
      *******************************/
66
-    public static function for(array $crudObject, array $definition): UploaderInterface
66
+    public static function for (array $crudObject, array $definition): UploaderInterface
67 67
     {
68 68
         return new static($crudObject, $definition);
69 69
     }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     public function deleteUploadedFiles(Model $entry): void
105 105
     {
106 106
         if ($this->deleteWhenEntryIsDeleted) {
107
-            if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) {
107
+            if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) {
108 108
                 $this->performFileDeletion($entry);
109 109
 
110 110
                 return;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
     public function getPreviousFiles(Model $entry): mixed
182 182
     {
183
-        if (! $this->attachedToFakeField) {
183
+        if (!$this->attachedToFakeField) {
184 184
             return $this->getOriginalValue($entry);
185 185
         }
186 186
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $value = $entry->{$this->getAttributeName()};
220 220
 
221 221
         if ($this->handleMultipleFiles) {
222
-            if (! isset($entry->getCasts()[$this->getName()]) && is_string($value)) {
222
+            if (!isset($entry->getCasts()[$this->getName()]) && is_string($value)) {
223 223
                 $entry->{$this->getAttributeName()} = json_decode($value, true);
224 224
             }
225 225
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
         if ($this->handleMultipleFiles) {
253 253
             // ensure we have an array of values when field is not casted in model.
254
-            if (! isset($entry->getCasts()[$this->name]) && is_string($values)) {
254
+            if (!isset($entry->getCasts()[$this->name]) && is_string($values)) {
255 255
                 $values = json_decode($values, true);
256 256
             }
257 257
             foreach ($values ?? [] as $value) {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 
269 269
     private function performFileDeletion(Model $entry)
270 270
     {
271
-        if (! $this->handleRepeatableFiles) {
271
+        if (!$this->handleRepeatableFiles) {
272 272
             $this->deleteFiles($entry);
273 273
 
274 274
             return;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
         $previousValue = $entry->getOriginal($field ?? $this->getAttributeName());
297 297
 
298
-        if (! $previousValue) {
298
+        if (!$previousValue) {
299 299
             return $previousValue;
300 300
         }
301 301
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
     /**
314 314
      * Given two multidimensional arrays/collections, merge them recursively.
315 315
      */
316
-    public static function mergeFilesAndValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection
316
+    public static function mergeFilesAndValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection
317 317
     {
318 318
         $merged = $array1;
319 319
         foreach ($array2 as $key => &$value) {
Please login to merge, or discard this patch.