@@ -6,6 +6,6 @@ |
||
| 6 | 6 | { |
| 7 | 7 | public function __construct() |
| 8 | 8 | { |
| 9 | - $this->message = trans('laravel-filemanager::lfm.error-file-size', ['max' => ini_get('upload_max_filesize')]); |
|
| 9 | + $this->message = trans('laravel-filemanager::lfm.error-file-size', [ 'max' => ini_get('upload_max_filesize') ]); |
|
| 10 | 10 | } |
| 11 | 11 | } |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function getErrors() |
| 48 | 48 | { |
| 49 | - $arr_errors = []; |
|
| 49 | + $arr_errors = [ ]; |
|
| 50 | 50 | |
| 51 | - if (! extension_loaded('gd') && ! extension_loaded('imagick')) { |
|
| 51 | + if (!extension_loaded('gd') && !extension_loaded('imagick')) { |
|
| 52 | 52 | array_push($arr_errors, trans('laravel-filemanager::lfm.message-extension_not_found')); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! extension_loaded('exif')) { |
|
| 55 | + if (!extension_loaded('exif')) { |
|
| 56 | 56 | array_push($arr_errors, 'EXIF extension not found.'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if (! extension_loaded('fileinfo')) { |
|
| 59 | + if (!extension_loaded('fileinfo')) { |
|
| 60 | 60 | array_push($arr_errors, 'Fileinfo extension not found.'); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | . $this->helper->currentLfmType() |
| 65 | 65 | . '.valid_mime'; |
| 66 | 66 | |
| 67 | - if (! is_array(config($mine_config_key))) { |
|
| 67 | + if (!is_array(config($mine_config_key))) { |
|
| 68 | 68 | array_push($arr_errors, 'Config : ' . $mine_config_key . ' is not a valid array.'); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | */ |
| 79 | 79 | public function applyIniOverrides() |
| 80 | 80 | { |
| 81 | - $overrides = config('lfm.php_ini_overrides', []); |
|
| 81 | + $overrides = config('lfm.php_ini_overrides', [ ]); |
|
| 82 | 82 | |
| 83 | 83 | if ($overrides && is_array($overrides) && count($overrides) === 0) { |
| 84 | 84 | return; |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __construct() |
| 16 | 16 | { |
| 17 | 17 | parent::__construct(); |
| 18 | - $this->errors = []; |
|
| 18 | + $this->errors = [ ]; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | public function upload() |
| 29 | 29 | { |
| 30 | 30 | $uploaded_files = request()->file('upload'); |
| 31 | - $error_bag = []; |
|
| 31 | + $error_bag = [ ]; |
|
| 32 | 32 | $new_filename = null; |
| 33 | 33 | |
| 34 | - foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) { |
|
| 34 | + foreach (is_array($uploaded_files) ? $uploaded_files : [ $uploaded_files ] as $file) { |
|
| 35 | 35 | try { |
| 36 | 36 | $this->lfm->validateUploadedFile($file); |
| 37 | 37 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } else { // upload via ckeditor5 expects json responses |
| 52 | 52 | if (is_null($new_filename)) { |
| 53 | 53 | $response = [ |
| 54 | - 'error' => [ 'message' => $error_bag[0] ] |
|
| 54 | + 'error' => [ 'message' => $error_bag[ 0 ] ] |
|
| 55 | 55 | ]; |
| 56 | 56 | } else { |
| 57 | 57 | $url = $this->lfm->setName($new_filename)->url(); |
@@ -12,26 +12,25 @@ discard block |
||
| 12 | 12 | private $isDirectory; |
| 13 | 13 | private $mimeType = null; |
| 14 | 14 | |
| 15 | - private $columns = []; |
|
| 16 | - public $attributes = []; |
|
| 15 | + private $columns = [ ]; |
|
| 16 | + public $attributes = [ ]; |
|
| 17 | 17 | |
| 18 | 18 | public function __construct(LfmPath $lfm, Lfm $helper, $isDirectory = false) |
| 19 | 19 | { |
| 20 | 20 | $this->lfm = $lfm->thumb(false); |
| 21 | 21 | $this->helper = $helper; |
| 22 | 22 | $this->isDirectory = $isDirectory; |
| 23 | - $this->columns = $helper->config('item_columns') ?: |
|
| 24 | - ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']; |
|
| 23 | + $this->columns = $helper->config('item_columns') ?: [ 'name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url' ]; |
|
| 25 | 24 | } |
| 26 | 25 | |
| 27 | 26 | public function __get($var_name) |
| 28 | 27 | { |
| 29 | 28 | if (!array_key_exists($var_name, $this->attributes)) { |
| 30 | 29 | $function_name = Str::camel($var_name); |
| 31 | - $this->attributes[$var_name] = $this->$function_name(); |
|
| 30 | + $this->attributes[ $var_name ] = $this->$function_name(); |
|
| 32 | 31 | } |
| 33 | 32 | |
| 34 | - return $this->attributes[$var_name]; |
|
| 33 | + return $this->attributes[ $var_name ]; |
|
| 35 | 34 | } |
| 36 | 35 | |
| 37 | 36 | public function fill() |
@@ -60,7 +59,7 @@ discard block |
||
| 60 | 59 | |
| 61 | 60 | public function isFile() |
| 62 | 61 | { |
| 63 | - return ! $this->isDirectory(); |
|
| 62 | + return !$this->isDirectory(); |
|
| 64 | 63 | } |
| 65 | 64 | |
| 66 | 65 | /** |
@@ -175,7 +174,7 @@ discard block |
||
| 175 | 174 | return false; |
| 176 | 175 | } |
| 177 | 176 | |
| 178 | - if (in_array($this->mimeType(), ['image/gif', 'image/svg+xml'])) { |
|
| 177 | + if (in_array($this->mimeType(), [ 'image/gif', 'image/svg+xml' ])) { |
|
| 179 | 178 | return false; |
| 180 | 179 | } |
| 181 | 180 | |
@@ -196,9 +195,9 @@ discard block |
||
| 196 | 195 | */ |
| 197 | 196 | public function humanFilesize($bytes, $decimals = 2) |
| 198 | 197 | { |
| 199 | - $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
|
| 198 | + $size = [ 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; |
|
| 200 | 199 | $factor = floor((strlen($bytes) - 1) / 3); |
| 201 | 200 | |
| 202 | - return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[$factor]); |
|
| 201 | + return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[ $factor ]); |
|
| 203 | 202 | } |
| 204 | 203 | } |
@@ -114,10 +114,10 @@ |
||
| 114 | 114 | 'over_write_on_duplicate' => false, |
| 115 | 115 | |
| 116 | 116 | // mimetypes of executables to prevent from uploading |
| 117 | - 'disallowed_mimetypes' => ['text/x-php', 'text/html', 'text/plain'], |
|
| 117 | + 'disallowed_mimetypes' => [ 'text/x-php', 'text/html', 'text/plain' ], |
|
| 118 | 118 | |
| 119 | 119 | // Item Columns |
| 120 | - 'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'], |
|
| 120 | + 'item_columns' => [ 'name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url' ], |
|
| 121 | 121 | |
| 122 | 122 | /* |
| 123 | 123 | |-------------------------------------------------------------------------- |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | public function folders() |
| 98 | 98 | { |
| 99 | - $all_folders = array_map(function ($directory_path) { |
|
| 99 | + $all_folders = array_map(function($directory_path) { |
|
| 100 | 100 | return $this->pretty($directory_path, true); |
| 101 | 101 | }, $this->storage->directories()); |
| 102 | 102 | |
| 103 | - $folders = array_filter($all_folders, function ($directory) { |
|
| 103 | + $folders = array_filter($all_folders, function($directory) { |
|
| 104 | 104 | return $directory->name !== $this->helper->getThumbFolderName(); |
| 105 | 105 | }); |
| 106 | 106 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | public function files() |
| 111 | 111 | { |
| 112 | - $files = array_map(function ($file_path) { |
|
| 112 | + $files = array_map(function($file_path) { |
|
| 113 | 113 | return $this->pretty($file_path); |
| 114 | 114 | }, $this->storage->files()); |
| 115 | 115 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $working_dir = $this->path('working_dir'); |
| 155 | 155 | $parent_dir = substr($working_dir, 0, strrpos($working_dir, '/')); |
| 156 | 156 | |
| 157 | - $parent_directories = array_map(function ($directory_path) { |
|
| 157 | + $parent_directories = array_map(function($directory_path) { |
|
| 158 | 158 | return app(static::class)->translateToLfmPath($directory_path); |
| 159 | 159 | }, app(static::class)->dir($parent_dir)->directories()); |
| 160 | 160 | |
@@ -200,20 +200,20 @@ discard block |
||
| 200 | 200 | public function sortByColumn($arr_items) |
| 201 | 201 | { |
| 202 | 202 | $sort_by = $this->helper->input('sort_type'); |
| 203 | - if (in_array($sort_by, ['name', 'time'])) { |
|
| 203 | + if (in_array($sort_by, [ 'name', 'time' ])) { |
|
| 204 | 204 | $key_to_sort = $sort_by; |
| 205 | 205 | } else { |
| 206 | 206 | $key_to_sort = 'name'; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - uasort($arr_items, function ($a, $b) use ($key_to_sort) { |
|
| 209 | + uasort($arr_items, function($a, $b) use ($key_to_sort) { |
|
| 210 | 210 | return strcasecmp($a->{$key_to_sort}, $b->{$key_to_sort}); |
| 211 | 211 | }); |
| 212 | 212 | |
| 213 | 213 | return $arr_items; |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - public function error($error_type, $variables = []) |
|
| 216 | + public function error($error_type, $variables = [ ]) |
|
| 217 | 217 | { |
| 218 | 218 | throw new \Exception($this->helper->error($error_type, $variables)); |
| 219 | 219 | } |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | $validator->nameIsNotDuplicate($this->getNewName($file), $this); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $validator->isNotExcutable(config('lfm.disallowed_mimetypes', ['text/x-php', 'text/html', 'text/plain'])); |
|
| 256 | + $validator->isNotExcutable(config('lfm.disallowed_mimetypes', [ 'text/x-php', 'text/html', 'text/plain' ])); |
|
| 257 | 257 | |
| 258 | 258 | if (config('lfm.should_validate_mime', false)) { |
| 259 | 259 | $validator->mimeTypeIsValid($this->helper->availableMimeTypes()); |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | $file_name_without_extentions = $new_file_name; |
| 290 | 290 | while ($this->setName(($extension) ? $new_file_name_with_extention : $new_file_name)->exists()) { |
| 291 | 291 | if (config('lfm.alphanumeric_filename') === true) { |
| 292 | - $suffix = '_'.$counter; |
|
| 292 | + $suffix = '_' . $counter; |
|
| 293 | 293 | } else { |
| 294 | 294 | $suffix = " ({$counter})"; |
| 295 | 295 | } |
| 296 | - $new_file_name = $file_name_without_extentions.$suffix; |
|
| 296 | + $new_file_name = $file_name_without_extentions . $suffix; |
|
| 297 | 297 | |
| 298 | 298 | if ($extension) { |
| 299 | 299 | $new_file_name_with_extention = $new_file_name . '.' . $extension; |