@@ -12,25 +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')??['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' ]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function __get($var_name) |
27 | 27 | { |
28 | 28 | if (!array_key_exists($var_name, $this->attributes)) { |
29 | 29 | $function_name = Str::camel($var_name); |
30 | - $this->attributes[$var_name] = $this->$function_name(); |
|
30 | + $this->attributes[ $var_name ] = $this->$function_name(); |
|
31 | 31 | } |
32 | 32 | |
33 | - return $this->attributes[$var_name]; |
|
33 | + return $this->attributes[ $var_name ]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function fill() |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | public function isFile() |
61 | 61 | { |
62 | - return ! $this->isDirectory(); |
|
62 | + return !$this->isDirectory(); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | return false; |
175 | 175 | } |
176 | 176 | |
177 | - if (in_array($this->mimeType(), ['image/gif', 'image/svg+xml'])) { |
|
177 | + if (in_array($this->mimeType(), [ 'image/gif', 'image/svg+xml' ])) { |
|
178 | 178 | return false; |
179 | 179 | } |
180 | 180 | |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function humanFilesize($bytes, $decimals = 2) |
197 | 197 | { |
198 | - $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
|
198 | + $size = [ 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; |
|
199 | 199 | $factor = floor((strlen($bytes) - 1) / 3); |
200 | 200 | |
201 | - return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[$factor]); |
|
201 | + return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[ $factor ]); |
|
202 | 202 | } |
203 | 203 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function getDelete() |
17 | 17 | { |
18 | 18 | $item_names = request('items'); |
19 | - $errors = []; |
|
19 | + $errors = [ ]; |
|
20 | 20 | |
21 | 21 | foreach ($item_names as $name_to_delete) { |
22 | 22 | $file = $this->lfm->setName($name_to_delete); |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | continue; |
36 | 36 | } |
37 | 37 | |
38 | - if (! $this->lfm->setName($name_to_delete)->exists()) { |
|
39 | - array_push($errors, parent::error('folder-not-found', ['folder' => $file_path])); |
|
38 | + if (!$this->lfm->setName($name_to_delete)->exists()) { |
|
39 | + array_push($errors, parent::error('folder-not-found', [ 'folder' => $file_path ])); |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
43 | 43 | if ($this->lfm->setName($name_to_delete)->isDirectory()) { |
44 | - if (! $this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
44 | + if (!$this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
45 | 45 | array_push($errors, parent::error('delete-folder')); |
46 | 46 | continue; |
47 | 47 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | public function folders() |
92 | 92 | { |
93 | - $all_folders = array_map(function ($directory_path) { |
|
93 | + $all_folders = array_map(function($directory_path) { |
|
94 | 94 | return $this->pretty($directory_path, true); |
95 | 95 | }, $this->storage->directories()); |
96 | 96 | |
97 | - $folders = array_filter($all_folders, function ($directory) { |
|
97 | + $folders = array_filter($all_folders, function($directory) { |
|
98 | 98 | return $directory->name !== $this->helper->getThumbFolderName(); |
99 | 99 | }); |
100 | 100 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | public function files() |
105 | 105 | { |
106 | - $files = array_map(function ($file_path) { |
|
106 | + $files = array_map(function($file_path) { |
|
107 | 107 | return $this->pretty($file_path); |
108 | 108 | }, $this->storage->files()); |
109 | 109 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $working_dir = $this->path('working_dir'); |
149 | 149 | $parent_dir = substr($working_dir, 0, strrpos($working_dir, '/')); |
150 | 150 | |
151 | - $parent_directories = array_map(function ($directory_path) { |
|
151 | + $parent_directories = array_map(function($directory_path) { |
|
152 | 152 | return app(static::class)->translateToLfmPath($directory_path); |
153 | 153 | }, app(static::class)->dir($parent_dir)->directories()); |
154 | 154 | |
@@ -194,20 +194,20 @@ discard block |
||
194 | 194 | public function sortByColumn($arr_items) |
195 | 195 | { |
196 | 196 | $sort_by = $this->helper->input('sort_type'); |
197 | - if (in_array($sort_by, ['name', 'time'])) { |
|
197 | + if (in_array($sort_by, [ 'name', 'time' ])) { |
|
198 | 198 | $key_to_sort = $sort_by; |
199 | 199 | } else { |
200 | 200 | $key_to_sort = 'name'; |
201 | 201 | } |
202 | 202 | |
203 | - uasort($arr_items, function ($a, $b) use ($key_to_sort) { |
|
203 | + uasort($arr_items, function($a, $b) use ($key_to_sort) { |
|
204 | 204 | return strcasecmp($a->{$key_to_sort}, $b->{$key_to_sort}); |
205 | 205 | }); |
206 | 206 | |
207 | 207 | return $arr_items; |
208 | 208 | } |
209 | 209 | |
210 | - public function error($error_type, $variables = []) |
|
210 | + public function error($error_type, $variables = [ ]) |
|
211 | 211 | { |
212 | 212 | throw new \Exception($this->helper->error($error_type, $variables)); |
213 | 213 | } |
@@ -236,10 +236,10 @@ discard block |
||
236 | 236 | { |
237 | 237 | if (empty($file)) { |
238 | 238 | return $this->error('file-empty'); |
239 | - } elseif (! $file instanceof UploadedFile) { |
|
239 | + } elseif (!$file instanceof UploadedFile) { |
|
240 | 240 | return $this->error('instance'); |
241 | 241 | } elseif ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
242 | - return $this->error('file-size', ['max' => ini_get('upload_max_filesize')]); |
|
242 | + return $this->error('file-size', [ 'max' => ini_get('upload_max_filesize') ]); |
|
243 | 243 | } elseif ($file->getError() != UPLOAD_ERR_OK) { |
244 | 244 | throw new \Exception('File failed to upload. Error code: ' . $file->getError()); |
245 | 245 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | $mimetype = $file->getMimeType(); |
254 | 254 | |
255 | - $excutable = ['text/x-php']; |
|
255 | + $excutable = [ 'text/x-php' ]; |
|
256 | 256 | |
257 | 257 | if (in_array($mimetype, $excutable)) { |
258 | 258 | throw new \Exception('Invalid file detected'); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | $file_name_without_extentions = $new_file_name; |
298 | 298 | while ($this->setName(($extension) ? $new_file_name_with_extention : $new_file_name)->exists()) { |
299 | 299 | if (config('lfm.alphanumeric_filename') === true) { |
300 | - $suffix = '_'.$counter; |
|
300 | + $suffix = '_' . $counter; |
|
301 | 301 | } else { |
302 | 302 | $suffix = " ({$counter})"; |
303 | 303 | } |
304 | - $new_file_name = $file_name_without_extentions.$suffix; |
|
304 | + $new_file_name = $file_name_without_extentions . $suffix; |
|
305 | 305 | |
306 | 306 | if ($extension) { |
307 | 307 | $new_file_name_with_extention = $new_file_name . '.' . $extension; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $path_parts = pathinfo($path); |
62 | 62 | } |
63 | 63 | |
64 | - return substr($path_parts[$part_name], 1); |
|
64 | + return substr($path_parts[ $part_name ], 1); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public function allowFolderType($type) |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $lfm_type = 'file'; |
91 | 91 | |
92 | 92 | $request_type = lcfirst(Str::singular($this->input('type') ?: '')); |
93 | - $available_types = array_keys($this->config->get('lfm.folder_categories') ?: []); |
|
93 | + $available_types = array_keys($this->config->get('lfm.folder_categories') ?: [ ]); |
|
94 | 94 | |
95 | 95 | if (in_array($request_type, $available_types)) { |
96 | 96 | $lfm_type = $request_type; |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $view_type = 'grid'; |
108 | 108 | $target_display_type = $this->input('show_list') ?: $startup_view; |
109 | 109 | |
110 | - if (in_array($target_display_type, ['list', 'grid'])) { |
|
110 | + if (in_array($target_display_type, [ 'list', 'grid' ])) { |
|
111 | 111 | $view_type = $target_display_type; |
112 | 112 | } |
113 | 113 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function allowShareFolder() |
193 | 193 | { |
194 | - if (! $this->allowMultiUser()) { |
|
194 | + if (!$this->allowMultiUser()) { |
|
195 | 195 | return true; |
196 | 196 | } |
197 | 197 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param mixed $variables Variables the message needs. |
246 | 246 | * @return string |
247 | 247 | */ |
248 | - public function error($error_type, $variables = []) |
|
248 | + public function error($error_type, $variables = [ ]) |
|
249 | 249 | { |
250 | 250 | throw new \Exception(trans(self::PACKAGE_NAME . '::lfm.error-' . $error_type, $variables)); |
251 | 251 | } |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $as = 'unisharp.lfm.'; |
262 | 262 | $namespace = '\\UniSharp\\LaravelFilemanager\\Controllers\\'; |
263 | 263 | |
264 | - Route::group(compact('middleware', 'as', 'namespace'), function () { |
|
264 | + Route::group(compact('middleware', 'as', 'namespace'), function() { |
|
265 | 265 | |
266 | 266 | // display main layout |
267 | 267 | Route::get('/', [ |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | public function __construct() |
15 | 15 | { |
16 | 16 | parent::__construct(); |
17 | - $this->errors = []; |
|
17 | + $this->errors = [ ]; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | public function upload() |
27 | 27 | { |
28 | 28 | $uploaded_files = request()->file('upload'); |
29 | - $error_bag = []; |
|
29 | + $error_bag = [ ]; |
|
30 | 30 | $new_filename = null; |
31 | 31 | |
32 | - foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) { |
|
32 | + foreach (is_array($uploaded_files) ? $uploaded_files : [ $uploaded_files ] as $file) { |
|
33 | 33 | try { |
34 | 34 | $new_filename = $this->lfm->upload($file); |
35 | 35 | } catch (\Exception $e) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } else { // upload via ckeditor5 expects json responses |
48 | 48 | if (is_null($new_filename)) { |
49 | 49 | $response = [ |
50 | - 'error' => [ 'message' => $error_bag[0] ] |
|
50 | + 'error' => [ 'message' => $error_bag[ 0 ] ] |
|
51 | 51 | ]; |
52 | 52 | } else { |
53 | 53 | $url = $this->lfm->setName($new_filename)->url(); |