Completed
Push — ft/media-validation ( f2aea2...121685 )
by Philippe
55:17 queued 43:45
created
src/Media/UploadMedia.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         if (isset(json_decode($file)->output)) {
114 114
             $image_name = json_decode($file)->output->name;
115 115
             $asset      = app(AddAsset::class)->add($model, json_decode($file)->output->image, $type, $locale, $this->sluggifyFilename($image_name));
116
-        } else {
116
+        }else {
117 117
             if ($file instanceof UploadedFile) {
118 118
                 $image_name = $file->getClientOriginalName();
119 119
                 $asset      = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name));
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
                 // New files are passed with their filename (instead of their id)
122 122
                 // For new files we will replace the filename with the id.
123 123
                 if (false !== ($key = array_search($image_name, $files_order))) {
124
-                    $files_order[$key] = (string) $asset->id;
124
+                    $files_order[$key] = (string)$asset->id;
125 125
                 }
126
-            } else {
126
+            }else {
127 127
                 $file       = Asset::findOrFail($file);
128 128
                 $asset      = app(AddAsset::class)->add($model, $file, $type, $locale);
129 129
             }
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function sluggifyFilename($filename): string
138 138
     {
139
-        $extension = substr($filename, strrpos($filename, '.') + 1);
139
+        $extension = substr($filename, strrpos($filename, '.')+1);
140 140
         $filename  = substr($filename, 0, strrpos($filename, '.'));
141
-        $filename  = Str::slug($filename) . '.' . $extension;
141
+        $filename  = Str::slug($filename).'.'.$extension;
142 142
 
143 143
         return $filename;
144 144
     }
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
                 if ($file instanceof UploadedFile && !$file->isValid()) {
155 155
                     if ($file->getError() == UPLOAD_ERR_INI_SIZE) {
156 156
                         throw new FileTooBigException(
157
-                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' .
158
-                            'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' .
159
-                            'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB'
157
+                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '.
158
+                            'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '.
159
+                            'post_max_size: '.(int)(ini_get('post_max_size')).'MB'
160 160
                         );
161 161
                     }
162 162
                 }
@@ -170,16 +170,16 @@  discard block
 block discarded – undo
170 170
         foreach ($files_by_type as $type => $files) {
171 171
             foreach ($files as $locale => $_files) {
172 172
                 if (!in_array($locale, config('translatable.locales'))) {
173
-                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.');
173
+                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.');
174 174
                 }
175 175
 
176 176
                 if (!is_array($_files)) {
177
-                    throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a ' . gettype($_files) . ' is given.');
177
+                    throw new \InvalidArgumentException('A valid files entry should be an array of files, key with either [new, replace or delete]. Instead a '.gettype($_files).' is given.');
178 178
                 }
179 179
 
180 180
                 foreach ($_files as $action => $file) {
181 181
                     if (!in_array($action, $actions)) {
182
-                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.');
182
+                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.');
183 183
                     }
184 184
                 }
185 185
             }
Please login to merge, or discard this patch.
src/Management/AbstractManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             return $this->indexPagination($builder);
88 88
         }
89 89
 
90
-        return $builder->get()->map(function ($model) {
90
+        return $builder->get()->map(function($model) {
91 91
             return (new static($this->registration))->manage($model);
92 92
         });
93 93
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $paginator = $builder->paginate($this->pageCount);
117 117
 
118
-        $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function ($model) {
118
+        $modifiedCollection = $builder->paginate($this->pageCount)->getCollection()->transform(function($model) {
119 119
             return (new static($this->registration))->manage($model);
120 120
         });
121 121
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
     public function guard($verb): Manager
194 194
     {
195
-        if (! $this->can($verb)) {
195
+        if (!$this->can($verb)) {
196 196
             NotAllowedManagerRoute::notAllowedVerb($verb, $this);
197 197
         }
198 198
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         $fields = $this->fields();
216 216
 
217 217
         foreach ($this->assistants() as $assistant) {
218
-            if (! method_exists($assistant, 'fields')) {
218
+            if (!method_exists($assistant, 'fields')) {
219 219
                 continue;
220 220
             }
221 221
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 
242 242
     public function delete()
243 243
     {
244
-        if($this->model instanceof ActsAsChild) {
244
+        if ($this->model instanceof ActsAsChild) {
245 245
             $this->model->detachAllParentRelations();
246 246
         }
247 247
 
248
-        if($this->model instanceof ActsAsParent) {
248
+        if ($this->model instanceof ActsAsParent) {
249 249
             $this->model->detachAllChildRelations();
250 250
         }
251 251
 
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
             static::$bootedTraitMethods[$baseMethod] = [];
306 306
 
307 307
             foreach (class_uses_recursive($class) as $trait) {
308
-                $method = class_basename($trait) . ucfirst($baseMethod);
308
+                $method = class_basename($trait).ucfirst($baseMethod);
309 309
 
310
-                if (method_exists($class, $method) && ! in_array($method, static::$bootedTraitMethods[$baseMethod])) {
310
+                if (method_exists($class, $method) && !in_array($method, static::$bootedTraitMethods[$baseMethod])) {
311 311
                     static::$bootedTraitMethods[$baseMethod][] = lcfirst($method);
312 312
                 }
313 313
             }
Please login to merge, or discard this patch.
src/Fields/ImageRequiredValidator.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,18 +6,18 @@
 block discarded – undo
6 6
 {
7 7
     public function validate($attribute, $values, $params, $validator)
8 8
     {
9
-        if(!isset($validator->attributes()['files'])) return false;
10
-        if(!isset($validator->attributes()['files'][$attribute])) return false;
9
+        if (!isset($validator->attributes()['files'])) return false;
10
+        if (!isset($validator->attributes()['files'][$attribute])) return false;
11 11
 
12 12
         $values = $validator->attributes()['files'][$attribute];
13 13
         
14
-        foreach($values as $locale => $value)
14
+        foreach ($values as $locale => $value)
15 15
         {
16 16
             $new     = isset($value['new']) ? count($value['new']) : 0;
17 17
             $replace = isset($value['replace']) ? count($value['replace']) : 0;
18 18
             $delete  = isset($value['delete']) ? count($value['delete']) : 0;
19 19
 
20
-            if ($new + $replace - $delete > 0) {
20
+            if ($new+$replace-$delete > 0) {
21 21
                 return true;
22 22
             }
23 23
     
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,8 +6,12 @@
 block discarded – undo
6 6
 {
7 7
     public function validate($attribute, $values, $params, $validator)
8 8
     {
9
-        if(!isset($validator->attributes()['files'])) return false;
10
-        if(!isset($validator->attributes()['files'][$attribute])) return false;
9
+        if(!isset($validator->attributes()['files'])) {
10
+            return false;
11
+        }
12
+        if(!isset($validator->attributes()['files'][$attribute])) {
13
+            return false;
14
+        }
11 15
 
12 16
         $values = $validator->attributes()['files'][$attribute];
13 17
         
Please login to merge, or discard this patch.
src/Fields/MediaDimensionsValidator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
     public function validate($attribute, $values, $params, $validator)
8 8
     {
9 9
         trap($values);
10
-        $params = array_reduce($params, function ($result, $item) {
10
+        $params = array_reduce($params, function($result, $item) {
11 11
             [$key, $value] = array_pad(explode('=', $item, 2), 2, null);
12 12
 
13 13
             $result[$key] = $value;
Please login to merge, or discard this patch.