We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -14,7 +14,7 @@ discard block |
||
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 |
||
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,10 +56,10 @@ discard block |
||
56 | 56 | |
57 | 57 | $processedEntryValues = $this->processRepeatableUploads($entry, $value); |
58 | 58 | |
59 | - if($this->isFake()) { |
|
59 | + if ($this->isFake()) { |
|
60 | 60 | $fakeValues = $entry->{$this->getFakeAttribute()} ?? []; |
61 | 61 | |
62 | - if(is_string($fakeValues)) { |
|
62 | + if (is_string($fakeValues)) { |
|
63 | 63 | $fakeValues = json_decode($fakeValues, true); |
64 | 64 | } |
65 | 65 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
159 | 159 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getAttributeName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
160 | 160 | |
161 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
161 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
162 | 162 | $item[$uploader->getAttributeName()] = $uploadedValues[$key] ?? null; |
163 | 163 | |
164 | 164 | return $item; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $values = $entry->{$this->getAttributeName()}; |
191 | 191 | $values = is_string($values) ? json_decode($values, true) : $values; |
192 | - $values = array_map(function ($item) use ($repeatableUploaders) { |
|
192 | + $values = array_map(function($item) use ($repeatableUploaders) { |
|
193 | 193 | foreach ($repeatableUploaders as $upload) { |
194 | 194 | $item[$upload->getAttributeName()] = $this->getValuesWithPathStripped($item, $upload); |
195 | 195 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | private function retrieveRepeatableRelationFiles(Model $entry) |
206 | 206 | { |
207 | - switch($this->getRepeatableRelationType()) { |
|
207 | + switch ($this->getRepeatableRelationType()) { |
|
208 | 208 | case 'BelongsToMany': |
209 | 209 | case 'MorphToMany': |
210 | 210 | $pivotClass = app('crud')->getModel()->{$this->getUploaderSubfield()['baseEntity']}()->getPivotClass(); |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | $repeatableValues ??= collect($entry->{$this->getRepeatableContainerName()}); |
258 | 258 | |
259 | 259 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
260 | - if (! $upload->shouldDeleteFiles()) { |
|
260 | + if (!$upload->shouldDeleteFiles()) { |
|
261 | 261 | continue; |
262 | 262 | } |
263 | 263 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
264 | 264 | foreach ($values as $value) { |
265 | - if (! $value) { |
|
265 | + if (!$value) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | /** |
286 | 286 | * Given two multidimensional arrays/collections, merge them recursively. |
287 | 287 | */ |
288 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
288 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
289 | 289 | { |
290 | 290 | $merged = $array1; |
291 | 291 | foreach ($array2 as $key => &$value) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | { |
308 | 308 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
309 | 309 | |
310 | - array_walk($items, function (&$key, $value) { |
|
310 | + array_walk($items, function(&$key, $value) { |
|
311 | 311 | $requestValue = $key[$this->getName()] ?? null; |
312 | 312 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
313 | 313 | }); |
@@ -319,22 +319,22 @@ discard block |
||
319 | 319 | { |
320 | 320 | $previousValues = $entry->getOriginal($uploader->getRepeatableContainerName()); |
321 | 321 | |
322 | - if (! is_array($previousValues)) { |
|
322 | + if (!is_array($previousValues)) { |
|
323 | 323 | $previousValues = json_decode($previousValues, true); |
324 | 324 | } |
325 | 325 | |
326 | - if (! empty($previousValues)) { |
|
326 | + if (!empty($previousValues)) { |
|
327 | 327 | $previousValues = array_column($previousValues, $uploader->getName()); |
328 | 328 | } |
329 | 329 | |
330 | 330 | return $previousValues ?? []; |
331 | 331 | } |
332 | 332 | |
333 | - private function getValuesWithPathStripped(array|string|null $item, UploaderInterface $uploader) |
|
333 | + private function getValuesWithPathStripped(array | string | null $item, UploaderInterface $uploader) |
|
334 | 334 | { |
335 | 335 | $uploadedValues = $item[$uploader->getName()] ?? null; |
336 | 336 | if (is_array($uploadedValues)) { |
337 | - return array_map(function ($value) use ($uploader) { |
|
337 | + return array_map(function($value) use ($uploader) { |
|
338 | 338 | return $uploader->getValueWithoutPath($value); |
339 | 339 | }, $uploadedValues); |
340 | 340 | } |
@@ -353,19 +353,19 @@ discard block |
||
353 | 353 | { |
354 | 354 | if (in_array($this->getRepeatableRelationType(), ['BelongsToMany', 'MorphToMany'])) { |
355 | 355 | $pivotAttributes = $entry->getAttributes(); |
356 | - $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function ($item) use ($pivotAttributes) { |
|
356 | + $connectedPivot = $entry->pivotParent->{$this->getRepeatableContainerName()}->where(function($item) use ($pivotAttributes) { |
|
357 | 357 | $itemPivotAttributes = $item->pivot->only(array_keys($pivotAttributes)); |
358 | 358 | |
359 | 359 | return $itemPivotAttributes === $pivotAttributes; |
360 | 360 | })->first(); |
361 | 361 | |
362 | - if (! $connectedPivot) { |
|
362 | + if (!$connectedPivot) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | 366 | $files = $connectedPivot->getOriginal()['pivot_'.$this->getAttributeName()]; |
367 | 367 | |
368 | - if (! $files) { |
|
368 | + if (!$files) { |
|
369 | 369 | return; |
370 | 370 | } |
371 | 371 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * Static constructor function. |
12 | 12 | */ |
13 | - public static function for(array $field, array $configuration): UploaderInterface; |
|
13 | + public static function for (array $field, array $configuration): UploaderInterface; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * Default implementation functions. |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function relationship(bool $isRelation): self; |
32 | 32 | |
33 | - public function fake(bool|string $isFake): self; |
|
33 | + public function fake(bool | string $isFake): self; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Getters. |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | public function getExpirationTimeInMinutes(): int; |
49 | 49 | |
50 | - public function getFileName(string|UploadedFile $file): string; |
|
50 | + public function getFileName(string | UploadedFile $file): string; |
|
51 | 51 | |
52 | 52 | public function getRepeatableContainerName(): ?string; |
53 | 53 | |
@@ -67,5 +67,5 @@ discard block |
||
67 | 67 | |
68 | 68 | public function isFake(): bool; |
69 | 69 | |
70 | - public function getFakeAttribute(): bool|string; |
|
70 | + public function getFakeAttribute(): bool | string; |
|
71 | 71 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private bool $deleteWhenEntryIsDeleted = true; |
27 | 27 | |
28 | - private bool|string $attachedToFakeField = false; |
|
28 | + private bool | string $attachedToFakeField = false; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Cloud disks have the ability to generate temporary URLs to files, should we do it? |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /******************************* |
63 | 63 | * Static methods |
64 | 64 | *******************************/ |
65 | - public static function for(array $crudObject, array $definition): UploaderInterface |
|
65 | + public static function for (array $crudObject, array $definition): UploaderInterface |
|
66 | 66 | { |
67 | 67 | return new static($crudObject, $definition); |
68 | 68 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | public function deleteUploadedFiles(Model $entry): void |
104 | 104 | { |
105 | 105 | if ($this->deleteWhenEntryIsDeleted) { |
106 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
106 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
107 | 107 | $this->performFileDeletion($entry); |
108 | 108 | |
109 | 109 | return; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | |
180 | 180 | public function getPreviousFiles(Model $entry): mixed |
181 | 181 | { |
182 | - if (! $this->attachedToFakeField) { |
|
182 | + if (!$this->attachedToFakeField) { |
|
183 | 183 | return $this->getOriginalValue($entry); |
184 | 184 | } |
185 | 185 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | return $this->attachedToFakeField !== false; |
200 | 200 | } |
201 | 201 | |
202 | - public function getFakeAttribute(): bool|string |
|
202 | + public function getFakeAttribute(): bool | string |
|
203 | 203 | { |
204 | 204 | return $this->attachedToFakeField; |
205 | 205 | } |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | return $this; |
222 | 222 | } |
223 | 223 | |
224 | - public function fake(bool|string $isFake): self |
|
224 | + public function fake(bool | string $isFake): self |
|
225 | 225 | { |
226 | 226 | $this->attachedToFakeField = $isFake; |
227 | 227 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | if ($this->handleMultipleFiles) { |
254 | - if (! isset($entry->getCasts()[$this->getName()]) && is_string($value)) { |
|
254 | + if (!isset($entry->getCasts()[$this->getName()]) && is_string($value)) { |
|
255 | 255 | $entry->{$this->getAttributeName()} = json_decode($value, true); |
256 | 256 | } |
257 | 257 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | |
266 | 266 | private function deleteFiles(Model $entry) |
267 | 267 | { |
268 | - if (! $this->shouldDeleteFiles()) { |
|
268 | + if (!$this->shouldDeleteFiles()) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | if ($this->handleMultipleFiles) { |
285 | 285 | // ensure we have an array of values when field is not casted in model. |
286 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
286 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
287 | 287 | $values = json_decode($values, true); |
288 | 288 | } |
289 | 289 | foreach ($values ?? [] as $value) { |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | |
301 | 301 | private function performFileDeletion(Model $entry) |
302 | 302 | { |
303 | - if (! $this->handleRepeatableFiles) { |
|
303 | + if (!$this->handleRepeatableFiles) { |
|
304 | 304 | $this->deleteFiles($entry); |
305 | 305 | |
306 | 306 | return; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | $previousValue = $entry->getOriginal($field); |
331 | 331 | |
332 | - if (! $previousValue) { |
|
332 | + if (!$previousValue) { |
|
333 | 333 | return $previousValue; |
334 | 334 | } |
335 | 335 |