We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -46,7 +46,7 @@ |
||
46 | 46 | if (isset($attributes['subfields'])) { |
47 | 47 | foreach ($attributes['subfields'] as $subfield) { |
48 | 48 | if (isset($subfield[$macro])) { |
49 | - $config = ! is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
49 | + $config = !is_array($subfield[$macro]) ? [] : $subfield[$macro]; |
|
50 | 50 | $this->{$macro}($config, $subfield); |
51 | 51 | } |
52 | 52 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | $value = $value ?? CRUD::getRequest()->get($this->getName()); |
15 | 15 | $previousImage = $entry->getOriginal($this->getName()); |
16 | 16 | |
17 | - if (! $value && $previousImage) { |
|
17 | + if (!$value && $previousImage) { |
|
18 | 18 | Storage::disk($this->getDisk())->delete($previousImage); |
19 | 19 | |
20 | 20 | return null; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | |
11 | 11 | class MultipleFiles extends Uploader |
12 | 12 | { |
13 | - public static function for(array $field, $configuration): UploaderInterface |
|
13 | + public static function for (array $field, $configuration): UploaderInterface |
|
14 | 14 | { |
15 | 15 | return (new self($field, $configuration))->multiple(); |
16 | 16 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $value = $value ?? CRUD::getRequest()->file($this->getName()); |
22 | 22 | $previousFiles = $entry->getOriginal($this->getName()) ?? []; |
23 | 23 | |
24 | - if (! is_array($previousFiles) && is_string($previousFiles)) { |
|
24 | + if (!is_array($previousFiles) && is_string($previousFiles)) { |
|
25 | 25 | $previousFiles = json_decode($previousFiles, true); |
26 | 26 | } |
27 | 27 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (in_array($previousFile, $filesToDelete)) { |
31 | 31 | Storage::disk($this->getDisk())->delete($previousFile); |
32 | 32 | |
33 | - $previousFiles = Arr::where($previousFiles, function ($value, $key) use ($previousFile) { |
|
33 | + $previousFiles = Arr::where($previousFiles, function($value, $key) use ($previousFile) { |
|
34 | 34 | return $value != $previousFile; |
35 | 35 | }); |
36 | 36 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | return $this->getPath().$fileName; |
24 | 24 | } |
25 | 25 | |
26 | - if (! $value && CrudPanelFacade::getRequest()->has($this->getName()) && $previousFile) { |
|
26 | + if (!$value && CrudPanelFacade::getRequest()->has($this->getName()) && $previousFile) { |
|
27 | 27 | Storage::disk($this->getDisk())->delete($previousFile); |
28 | 28 | |
29 | 29 | return null; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | foreach ($previousRepeatableValues as $row => $file) { |
50 | - if ($file && ! isset($orderedFiles[$row])) { |
|
50 | + if ($file && !isset($orderedFiles[$row])) { |
|
51 | 51 | $orderedFiles[$row] = null; |
52 | 52 | Storage::disk($this->getDisk())->delete($file); |
53 | 53 | } |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | private string $crudObjectType; |
14 | 14 | |
15 | 15 | public function __construct( |
16 | - private readonly CrudField|CrudColumn $crudObject, |
|
16 | + private readonly CrudField | CrudColumn $crudObject, |
|
17 | 17 | private readonly array $uploaderConfiguration, |
18 | 18 | private readonly string $macro |
19 | 19 | ) { |
20 | 20 | $this->crudObjectType = is_a($crudObject, CrudField::class) ? 'field' : (is_a($crudObject, CrudColumn::class) ? 'column' : null); |
21 | 21 | |
22 | - if (! $this->crudObjectType) { |
|
22 | + if (!$this->crudObjectType) { |
|
23 | 23 | abort(500, 'Upload handlers only work for CrudField and CrudColumn classes.'); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | - public static function handle(CrudField|CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null): void |
|
27 | + public static function handle(CrudField | CrudColumn $crudObject, array $uploaderConfiguration, string $macro, ?array $subfield = null): void |
|
28 | 28 | { |
29 | 29 | $instance = new self($crudObject, $uploaderConfiguration, $macro); |
30 | 30 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | /******************************* |
35 | 35 | * Private methods - implementation |
36 | 36 | *******************************/ |
37 | - private function registerEvents(array|null $subfield = []): void |
|
37 | + private function registerEvents(array | null $subfield = []): void |
|
38 | 38 | { |
39 | - if (! empty($subfield)) { |
|
39 | + if (!empty($subfield)) { |
|
40 | 40 | $this->registerSubfieldEvent($subfield); |
41 | 41 | |
42 | 42 | return; |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | |
72 | 72 | // for subfields, we only register one event so that we have access to the repeatable container name. |
73 | 73 | // all the uploaders for a given container are stored in the UploadersRepository. |
74 | - if (! app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
74 | + if (!app('UploadersRepository')->hasRepeatableUploadersFor($uploader->getRepeatableContainerName())) { |
|
75 | 75 | $this->setupModelEvents($model, $uploader); |
76 | 76 | } |
77 | 77 | |
78 | 78 | $subfields = collect($this->crudObject->getAttributes()['subfields']); |
79 | - $subfields = $subfields->map(function ($item) use ($subfield, $uploader) { |
|
79 | + $subfields = $subfields->map(function($item) use ($subfield, $uploader) { |
|
80 | 80 | if ($item['name'] === $subfield['name']) { |
81 | 81 | $item['upload'] = true; |
82 | 82 | $item['disk'] = $uploader->getDisk(); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($this->crudObjectType === 'field') { |
109 | - $model::saving(function ($entry) use ($uploader) { |
|
109 | + $model::saving(function($entry) use ($uploader) { |
|
110 | 110 | $updatedCountKey = 'uploaded_'.($uploader->getRepeatableContainerName() ?? $uploader->getName()).'_count'; |
111 | 111 | |
112 | 112 | CRUD::set($updatedCountKey, CRUD::get($updatedCountKey) ?? 0); |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | }); |
118 | 118 | } |
119 | 119 | |
120 | - $model::retrieved(function ($entry) use ($uploader) { |
|
120 | + $model::retrieved(function($entry) use ($uploader) { |
|
121 | 121 | $entry = $uploader->retrieveUploadedFiles($entry); |
122 | 122 | }); |
123 | 123 | |
124 | - $model::deleting(function ($entry) use ($uploader) { |
|
124 | + $model::deleting(function($entry) use ($uploader) { |
|
125 | 125 | $uploader->deleteUploadedFiles($entry); |
126 | 126 | }); |
127 | 127 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $customUploader = isset($uploaderConfiguration['uploader']) && class_exists($uploaderConfiguration['uploader']); |
145 | 145 | |
146 | 146 | if ($customUploader) { |
147 | - return $uploaderConfiguration['uploader']::for($crudObject, $uploaderConfiguration); |
|
147 | + return $uploaderConfiguration['uploader']::for ($crudObject, $uploaderConfiguration); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $uploader = app('UploadersRepository')->hasUploadFor($crudObject['type'], $this->macro); |
151 | 151 | |
152 | 152 | if ($uploader) { |
153 | - return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for($crudObject, $uploaderConfiguration); |
|
153 | + return app('UploadersRepository')->getUploadFor($crudObject['type'], $this->macro)::for ($crudObject, $uploaderConfiguration); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | throw new Exception('Undefined upload type for '.$this->crudObjectType.' type: '.$crudObject['type']); |
@@ -6,5 +6,5 @@ |
||
6 | 6 | |
7 | 7 | interface FileNameGeneratorInterface |
8 | 8 | { |
9 | - public function getName(string|UploadedFile $file): string; |
|
9 | + public function getName(string | UploadedFile $file): string; |
|
10 | 10 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function markAsHandled(string $objectName): void |
33 | 33 | { |
34 | - if (! in_array($objectName, $this->handledUploaders)) { |
|
34 | + if (!in_array($objectName, $this->handledUploaders)) { |
|
35 | 35 | $this->handledUploaders[] = $objectName; |
36 | 36 | } |
37 | 37 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function registerRepeatableUploader(string $uploadName, UploaderInterface $uploader): void |
83 | 83 | { |
84 | - if (! array_key_exists($uploadName, $this->repeatableUploaders) || ! in_array($uploader, $this->repeatableUploaders[$uploadName])) { |
|
84 | + if (!array_key_exists($uploadName, $this->repeatableUploaders) || !in_array($uploader, $this->repeatableUploaders[$uploadName])) { |
|
85 | 85 | $this->repeatableUploaders[$uploadName][] = $uploader; |
86 | 86 | } |
87 | 87 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function getRegisteredUploadNames(string $uploadName): array |
117 | 117 | { |
118 | - return array_map(function ($uploader) { |
|
118 | + return array_map(function($uploader) { |
|
119 | 119 | return $uploader->getName(); |
120 | 120 | }, $this->getRepeatableUploadersFor($uploadName)); |
121 | 121 | } |
@@ -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. |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | public function getExpirationTimeInMinutes(): int; |
45 | 45 | |
46 | - public function getFileName(string|UploadedFile $file): string; |
|
46 | + public function getFileName(string | UploadedFile $file): string; |
|
47 | 47 | |
48 | 48 | public function getRepeatableContainerName(): ?string; |
49 | 49 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $uploader) { |
76 | 76 | $uploadedValues = $uploader->uploadRepeatableFiles($values->pluck($uploader->getName())->toArray(), $this->getPreviousRepeatableValues($entry, $uploader)); |
77 | 77 | |
78 | - $values = $values->map(function ($item, $key) use ($uploadedValues, $uploader) { |
|
78 | + $values = $values->map(function($item, $key) use ($uploadedValues, $uploader) { |
|
79 | 79 | $item[$uploader->getName()] = $uploadedValues[$key] ?? null; |
80 | 80 | |
81 | 81 | return $item; |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | |
105 | 105 | $repeatableValues = collect($entry->{$this->getName()}); |
106 | 106 | foreach (app('UploadersRepository')->getRepeatableUploadersFor($this->getRepeatableContainerName()) as $upload) { |
107 | - if (! $upload->shouldDeleteFiles()) { |
|
107 | + if (!$upload->shouldDeleteFiles()) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | $values = $repeatableValues->pluck($upload->getName())->toArray(); |
111 | 111 | foreach ($values as $value) { |
112 | - if (! $value) { |
|
112 | + if (!$value) { |
|
113 | 113 | continue; |
114 | 114 | } |
115 | 115 | |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * Given two multidimensional arrays/collections, merge them recursively. |
134 | 134 | */ |
135 | - protected function mergeValuesRecursive(array|Collection $array1, array|Collection $array2): array|Collection |
|
135 | + protected function mergeValuesRecursive(array | Collection $array1, array | Collection $array2): array | Collection |
|
136 | 136 | { |
137 | 137 | $merged = $array1; |
138 | 138 | foreach ($array2 as $key => &$value) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | { |
155 | 155 | $items = CRUD::getRequest()->input('_order_'.$this->getRepeatableContainerName()) ?? []; |
156 | 156 | |
157 | - array_walk($items, function (&$key, $value) { |
|
157 | + array_walk($items, function(&$key, $value) { |
|
158 | 158 | $requestValue = $key[$this->getName()] ?? null; |
159 | 159 | $key = $this->handleMultipleFiles ? (is_string($requestValue) ? explode(',', $requestValue) : $requestValue) : $requestValue; |
160 | 160 | }); |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | { |
167 | 167 | $previousValues = json_decode($entry->getOriginal($uploader->getRepeatableContainerName()), true); |
168 | 168 | |
169 | - if (! empty($previousValues)) { |
|
169 | + if (!empty($previousValues)) { |
|
170 | 170 | $previousValues = array_column($previousValues, $uploader->getName()); |
171 | 171 | } |
172 | 172 |