Passed
Push — ft/mediagallery-existing-asset... ( a0579b...115e9e )
by Philippe
07:05
created
src/Media/UploadMedia.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -113,8 +113,8 @@  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 {
117
-            if($file instanceof UploadedFile)
116
+        }else {
117
+            if ($file instanceof UploadedFile)
118 118
             {
119 119
                 $image_name = $file->getClientOriginalName();
120 120
                 $asset      = app(AddAsset::class)->add($model, $file, $type, $locale, $this->sluggifyFilename($image_name));
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
                 // New files are passed with their filename (instead of their id)
123 123
                 // For new files we will replace the filename with the id.
124 124
                 if (false !== ($key = array_search($image_name, $files_order))) {
125
-                    $files_order[$key] = (string) $asset->id;
125
+                    $files_order[$key] = (string)$asset->id;
126 126
                 }
127
-            }else{
128
-                try{
127
+            }else {
128
+                try {
129 129
                     $file   = Asset::find($file);
130
-                    if(!$file) return;
130
+                    if (!$file) return;
131 131
                     $asset  = app(AddAsset::class)->add($model, $file, $type, $locale);
132
-                }catch(AssetUploadException $e)
132
+                } catch (AssetUploadException $e)
133 133
                 {
134 134
                 }
135 135
             }
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
      */
143 143
     private function sluggifyFilename($filename): string
144 144
     {
145
-        $extension = substr($filename, strrpos($filename, '.') + 1);
145
+        $extension = substr($filename, strrpos($filename, '.')+1);
146 146
         $filename  = substr($filename, 0, strrpos($filename, '.'));
147
-        $filename  = Str::slug($filename) . '.' . $extension;
147
+        $filename  = Str::slug($filename).'.'.$extension;
148 148
 
149 149
         return $filename;
150 150
     }
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
                 if ($file instanceof UploadedFile && !$file->isValid()) {
161 161
                     if ($file->getError() == UPLOAD_ERR_INI_SIZE) {
162 162
                         throw new FileTooBigException(
163
-                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. ' .
164
-                            'upload_max_filesize: ' . (int)ini_get('upload_max_filesize') . 'MB, ' .
165
-                            'post_max_size: ' . (int)(ini_get('post_max_size')) . 'MB'
163
+                            'Cannot upload file because it exceeded the allowed upload_max_filesize: upload_max_filesize is smaller than post size. '.
164
+                            'upload_max_filesize: '.(int)ini_get('upload_max_filesize').'MB, '.
165
+                            'post_max_size: '.(int)(ini_get('post_max_size')).'MB'
166 166
                         );
167 167
                     }
168 168
                 }
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
         foreach ($files_by_type as $type => $files) {
177 177
             foreach ($files as $locale => $_files) {
178 178
                 if (!in_array($locale, config('translatable.locales'))) {
179
-                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale [' . implode(',', config('translatable.locales', [])). ']. Instead [' . $locale . '] is given.');
179
+                    throw new \InvalidArgumentException('Corrupt file payload. key is expected to be a valid locale ['.implode(',', config('translatable.locales', [])).']. Instead ['.$locale.'] is given.');
180 180
                 }
181 181
 
182 182
                 if (!is_array($_files)) {
183
-                    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.');
183
+                    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.');
184 184
                 }
185 185
 
186 186
                 foreach ($_files as $action => $file) {
187 187
                     if (!in_array($action, $actions)) {
188
-                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead ' . $action . ' is given.');
188
+                        throw new \InvalidArgumentException('A valid files entry should have a key of either ['.implode(',', $actions).']. Instead '.$action.' is given.');
189 189
                     }
190 190
                 }
191 191
             }
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -124,12 +124,14 @@
 block discarded – undo
124 124
                 if (false !== ($key = array_search($image_name, $files_order))) {
125 125
                     $files_order[$key] = (string) $asset->id;
126 126
                 }
127
-            }else{
127
+            } else{
128 128
                 try{
129 129
                     $file   = Asset::find($file);
130
-                    if(!$file) return;
130
+                    if(!$file) {
131
+                        return;
132
+                    }
131 133
                     $asset  = app(AddAsset::class)->add($model, $file, $type, $locale);
132
-                }catch(AssetUploadException $e)
134
+                } catch(AssetUploadException $e)
133 135
                 {
134 136
                 }
135 137
             }
Please login to merge, or discard this patch.