We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /******************************* |
57 | 57 | * Static methods |
58 | 58 | *******************************/ |
59 | - public static function for(array $crudObject, array $definition): UploaderInterface |
|
59 | + public static function for (array $crudObject, array $definition): UploaderInterface |
|
60 | 60 | { |
61 | 61 | return new static($crudObject, $definition); |
62 | 62 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function deleteUploadedFiles(Model $entry): void |
88 | 88 | { |
89 | 89 | if ($this->deleteWhenEntryIsDeleted) { |
90 | - if (! in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
90 | + if (!in_array(SoftDeletes::class, class_uses_recursive($entry), true)) { |
|
91 | 91 | $this->performFileDeletion($entry); |
92 | 92 | |
93 | 93 | return; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $value = $entry->{$this->name}; |
176 | 176 | |
177 | 177 | if ($this->handleMultipleFiles) { |
178 | - if (! isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
178 | + if (!isset($entry->getCasts()[$this->name]) && is_string($value)) { |
|
179 | 179 | $entry->{$this->name} = json_decode($value, true); |
180 | 180 | } |
181 | 181 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | if ($this->handleMultipleFiles) { |
195 | 195 | // ensure we have an array of values when field is not casted in model. |
196 | - if (! isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
196 | + if (!isset($entry->getCasts()[$this->name]) && is_string($values)) { |
|
197 | 197 | $values = json_decode($values, true); |
198 | 198 | } |
199 | 199 | foreach ($values as $value) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | private function performFileDeletion(Model $entry) |
211 | 211 | { |
212 | - if ($this->isRelationship || ! $this->handleRepeatableFiles) { |
|
212 | + if ($this->isRelationship || !$this->handleRepeatableFiles) { |
|
213 | 213 | $this->deleteFiles($entry); |
214 | 214 | |
215 | 215 | return; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | class FileNameGenerator implements FileNameGeneratorInterface |
11 | 11 | { |
12 | - public function getName(string|UploadedFile|File $file): string |
|
12 | + public function getName(string | UploadedFile | File $file): string |
|
13 | 13 | { |
14 | 14 | if (is_object($file) && get_class($file) === File::class) { |
15 | 15 | return $file->getFileName(); |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | return $this->getFileName($file).'.'.$this->getExtensionFromFile($file); |
19 | 19 | } |
20 | 20 | |
21 | - private function getExtensionFromFile(string|UploadedFile $file): string |
|
21 | + private function getExtensionFromFile(string | UploadedFile $file): string |
|
22 | 22 | { |
23 | 23 | return is_a($file, UploadedFile::class, true) ? $file->extension() : Str::after(mime_content_type($file), '/'); |
24 | 24 | } |
25 | 25 | |
26 | - private function getFileName(string|UploadedFile $file): string |
|
26 | + private function getFileName(string | UploadedFile $file): string |
|
27 | 27 | { |
28 | 28 | if (is_file($file)) { |
29 | 29 | return Str::of($file->getClientOriginalName())->beforeLast('.')->slug()->append('-'.Str::random(4)); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function setValidation($classOrRulesArray = false, $messages = []) |
62 | 62 | { |
63 | - if (! $classOrRulesArray) { |
|
63 | + if (!$classOrRulesArray) { |
|
64 | 64 | $this->setValidationFromFields(); |
65 | 65 | } elseif (is_array($classOrRulesArray)) { |
66 | 66 | $this->setValidationFromArray($classOrRulesArray, $messages); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | return $this->checkRequestValidity($extendedRules, $extendedMessages, $formRequest); |
140 | 140 | } |
141 | 141 | |
142 | - return ! empty($rules) ? $this->checkRequestValidity($rules, $messages) : $this->getRequest(); |
|
142 | + return !empty($rules) ? $this->checkRequestValidity($rules, $messages) : $this->getRequest(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function isRequired($inputKey) |
226 | 226 | { |
227 | - if (! $this->hasOperationSetting('requiredFields')) { |
|
227 | + if (!$this->hasOperationSetting('requiredFields')) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | { |
246 | 246 | [$rules, $messages] = $this->getValidationRulesAndMessagesFromField($field, $parent); |
247 | 247 | |
248 | - if (! empty($rules)) { |
|
248 | + if (!empty($rules)) { |
|
249 | 249 | $this->setValidation($rules, $messages); |
250 | 250 | } |
251 | 251 | } |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | { |
261 | 261 | $messages = []; |
262 | 262 | collect($fields) |
263 | - ->filter(function ($value, $key) { |
|
263 | + ->filter(function($value, $key) { |
|
264 | 264 | // only keep fields where 'validationMessages' OR there are subfields |
265 | 265 | return array_key_exists('validationMessages', $value) || array_key_exists('subfields', $value); |
266 | - })->each(function ($item, $key) use (&$messages) { |
|
266 | + })->each(function($item, $key) use (&$messages) { |
|
267 | 267 | if (isset($item['validationMessages'])) { |
268 | 268 | foreach ($item['validationMessages'] as $rule => $message) { |
269 | 269 | $messages[$key.'.'.$rule] = $message; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | // add messages from subfields |
273 | 273 | if (array_key_exists('subfields', $item)) { |
274 | - $subfieldsWithValidationMessages = array_filter($item['subfields'], function ($subfield) { |
|
274 | + $subfieldsWithValidationMessages = array_filter($item['subfields'], function($subfield) { |
|
275 | 275 | return array_key_exists('validationRules', $subfield); |
276 | 276 | }); |
277 | 277 | |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | private function getValidationRulesFromFieldsAndSubfields($fields) |
296 | 296 | { |
297 | 297 | $rules = collect($fields) |
298 | - ->filter(function ($value, $key) { |
|
298 | + ->filter(function($value, $key) { |
|
299 | 299 | // only keep fields where 'validationRules' OR there are subfields |
300 | 300 | return array_key_exists('validationRules', $value) || array_key_exists('subfields', $value); |
301 | - })->map(function ($item, $key) { |
|
301 | + })->map(function($item, $key) { |
|
302 | 302 | $validationRules = []; |
303 | 303 | // only keep the rules, not the entire field definition |
304 | 304 | if (isset($item['validationRules'])) { |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | // add validation rules for subfields |
308 | 308 | if (array_key_exists('subfields', $item)) { |
309 | - $subfieldsWithValidation = array_filter($item['subfields'], function ($subfield) { |
|
309 | + $subfieldsWithValidation = array_filter($item['subfields'], function($subfield) { |
|
310 | 310 | return array_key_exists('validationRules', $subfield); |
311 | 311 | }); |
312 | 312 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | { |
365 | 365 | $extendedRules = []; |
366 | 366 | $requestRules = $this->getRequestRulesAsArray($request); |
367 | - $rules = array_map(function ($ruleDefinition) { |
|
367 | + $rules = array_map(function($ruleDefinition) { |
|
368 | 368 | return is_array($ruleDefinition) ? $ruleDefinition : explode('|', $ruleDefinition); |
369 | 369 | }, $rules); |
370 | 370 |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | */ |
18 | 18 | public function validate(string $attribute, mixed $value, Closure $fail): void |
19 | 19 | { |
20 | - if (! is_array($value)) { |
|
20 | + if (!is_array($value)) { |
|
21 | 21 | try { |
22 | 22 | $value = json_decode($value, true); |
23 | - } catch(\Exception $e) { |
|
23 | + } catch (\Exception $e) { |
|
24 | 24 | $fail('Unable to determine the value type'); |
25 | 25 | |
26 | 26 | return; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $value = array_merge($previousValues, $value); |
43 | 43 | |
44 | 44 | // if user uploaded something add it to the data beeing validated. |
45 | - if (! empty($value)) { |
|
45 | + if (!empty($value)) { |
|
46 | 46 | $this->data[$attribute] = $value; |
47 | 47 | } |
48 | 48 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function validate(string $attribute, mixed $value, Closure $fail): void |
50 | 50 | { |
51 | - if (! is_array($value)) { |
|
51 | + if (!is_array($value)) { |
|
52 | 52 | try { |
53 | 53 | $value = json_decode($value, true); |
54 | 54 | } catch (\Exception $e) { |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Set the rules that apply to the "array" aka the field, if it's required, min, max etc. |
93 | 93 | */ |
94 | - public function arrayRules(string|array|File $rules): self |
|
94 | + public function arrayRules(string | array | File $rules): self |
|
95 | 95 | { |
96 | 96 | if (is_string($rules)) { |
97 | 97 | $rules = explode('|', $rules); |
98 | 98 | } |
99 | 99 | |
100 | - if (! in_array('array', $rules)) { |
|
100 | + if (!in_array('array', $rules)) { |
|
101 | 101 | $rules[] = 'array'; |
102 | 102 | } |
103 | 103 | |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Set the rules that apply to the items beeing sent in array. |
111 | 111 | */ |
112 | - public function itemRules(string|array|File $rules): self |
|
112 | + public function itemRules(string | array | File $rules): self |
|
113 | 113 | { |
114 | 114 | if (is_string($rules)) { |
115 | 115 | $rules = explode('|', $rules); |
116 | 116 | } |
117 | 117 | |
118 | - if (! is_array($rules)) { |
|
118 | + if (!is_array($rules)) { |
|
119 | 119 | $rules = [$rules]; |
120 | 120 | } |
121 | 121 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function validateItemsAsArray($attribute, $items, $fail) |
159 | 159 | { |
160 | - if (! empty($this->namedItemRules)) { |
|
160 | + if (!empty($this->namedItemRules)) { |
|
161 | 161 | $this->validateNamedItemRules($attribute, $items, $fail); |
162 | 162 | } |
163 | 163 | |
@@ -212,12 +212,12 @@ discard block |
||
212 | 212 | }, array_keys($this->namedItemRules)), $this->namedItemRules); |
213 | 213 | |
214 | 214 | array_walk($this->namedItemRules, function(&$value, $key) { |
215 | - if(is_array($value)) { |
|
215 | + if (is_array($value)) { |
|
216 | 216 | $rules = []; |
217 | - foreach($value as $rule) { |
|
217 | + foreach ($value as $rule) { |
|
218 | 218 | if (is_a($rule, get_class($this), true)) { |
219 | - $validArrayRules = $rule->itemRules; |
|
220 | - if(is_array($validArrayRules)) { |
|
219 | + $validArrayRules = $rule->itemRules; |
|
220 | + if (is_array($validArrayRules)) { |
|
221 | 221 | $rules = array_merge($rules, $validArrayRules); |
222 | 222 | continue; |
223 | 223 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public function __call($method, $arguments) |
237 | 237 | { |
238 | 238 | // if method starts with `rule` eg: ruleName, extract the input name and add it to the array of rules |
239 | - if(Str::startsWith($method, 'rule')) { |
|
239 | + if (Str::startsWith($method, 'rule')) { |
|
240 | 240 | $argument = Str::snake(Str::replaceFirst('rule', '', $method)); |
241 | 241 | $this->namedItemRules[$argument] = $arguments[0]; |
242 | 242 | return $this; |