@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | |
96 | 96 | public function folders() |
97 | 97 | { |
98 | - $all_folders = array_map(function ($directory_path) { |
|
98 | + $all_folders = array_map(function($directory_path) { |
|
99 | 99 | return $this->pretty($directory_path); |
100 | 100 | }, $this->storage->directories()); |
101 | 101 | |
102 | - $folders = array_filter($all_folders, function ($directory) { |
|
102 | + $folders = array_filter($all_folders, function($directory) { |
|
103 | 103 | return $directory->name !== $this->helper->getThumbFolderName(); |
104 | 104 | }); |
105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | |
109 | 109 | public function files() |
110 | 110 | { |
111 | - $files = array_map(function ($file_path) { |
|
111 | + $files = array_map(function($file_path) { |
|
112 | 112 | return $this->pretty($file_path); |
113 | 113 | }, $this->storage->files()); |
114 | 114 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $working_dir = $this->path('working_dir'); |
153 | 153 | $parent_dir = substr($working_dir, 0, strrpos($working_dir, '/')); |
154 | 154 | |
155 | - $parent_directories = array_map(function ($directory_path) { |
|
155 | + $parent_directories = array_map(function($directory_path) { |
|
156 | 156 | return app(static::class)->translateToLfmPath($directory_path); |
157 | 157 | }, app(static::class)->dir($parent_dir)->directories()); |
158 | 158 | |
@@ -196,20 +196,20 @@ discard block |
||
196 | 196 | public function sortByColumn($arr_items) |
197 | 197 | { |
198 | 198 | $sort_by = $this->helper->input('sort_type'); |
199 | - if (in_array($sort_by, ['name', 'time'])) { |
|
199 | + if (in_array($sort_by, [ 'name', 'time' ])) { |
|
200 | 200 | $key_to_sort = $sort_by; |
201 | 201 | } else { |
202 | 202 | $key_to_sort = 'name'; |
203 | 203 | } |
204 | 204 | |
205 | - uasort($arr_items, function ($a, $b) use ($key_to_sort) { |
|
205 | + uasort($arr_items, function($a, $b) use ($key_to_sort) { |
|
206 | 206 | return strcmp($a->{$key_to_sort}, $b->{$key_to_sort}); |
207 | 207 | }); |
208 | 208 | |
209 | 209 | return $arr_items; |
210 | 210 | } |
211 | 211 | |
212 | - public function error($error_type, $variables = []) |
|
212 | + public function error($error_type, $variables = [ ]) |
|
213 | 213 | { |
214 | 214 | return $this->helper->error($error_type, $variables); |
215 | 215 | } |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | { |
239 | 239 | if (empty($file)) { |
240 | 240 | return $this->error('file-empty'); |
241 | - } elseif (! $file instanceof UploadedFile) { |
|
241 | + } elseif (!$file instanceof UploadedFile) { |
|
242 | 242 | return $this->error('instance'); |
243 | 243 | } elseif ($file->getError() == UPLOAD_ERR_INI_SIZE) { |
244 | - return $this->error('file-size', ['max' => ini_get('upload_max_filesize')]); |
|
244 | + return $this->error('file-size', [ 'max' => ini_get('upload_max_filesize') ]); |
|
245 | 245 | } elseif ($file->getError() != UPLOAD_ERR_OK) { |
246 | 246 | throw new \Exception('File failed to upload. Error code: ' . $file->getError()); |
247 | 247 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | private function checkDefaultFolderExists($type = 'share') |
29 | 29 | { |
30 | - if (! $this->helper->allowFolderType($type)) { |
|
30 | + if (!$this->helper->allowFolderType($type)) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | |
23 | 23 | if ($previous_dir == null) { |
24 | 24 | $request->merge(compact('working_dir')); |
25 | - } elseif (! $this->validDir($previous_dir)) { |
|
25 | + } elseif (!$this->validDir($previous_dir)) { |
|
26 | 26 | $request->replace(compact('working_dir')); |
27 | 27 | } |
28 | 28 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | { |
11 | 11 | $storage = Storage::disk($this->helper->config('disk')); |
12 | 12 | |
13 | - if (! $storage->exists($file_path)) { |
|
13 | + if (!$storage->exists($file_path)) { |
|
14 | 14 | abort(404); |
15 | 15 | } |
16 | 16 |
@@ -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) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $response = count($error_bag) > 0 ? $error_bag : parent::$success_response; |
47 | 47 | } else { // upload via ckeditor 'Upload' tab |
48 | 48 | if (is_null($new_filename)) { |
49 | - $response = $error_bag[0]; |
|
49 | + $response = $error_bag[ 0 ]; |
|
50 | 50 | } else { |
51 | 51 | $response = view(Lfm::PACKAGE_NAME . '::use') |
52 | 52 | ->withFile($this->lfm->setName($new_filename)->url()); |
@@ -31,9 +31,9 @@ |
||
31 | 31 | $image_path = $this->lfm->setName($image_name)->path('absolute'); |
32 | 32 | $crop_path = $image_path; |
33 | 33 | |
34 | - if (! $overWrite) { |
|
34 | + if (!$overWrite) { |
|
35 | 35 | $fileParts = explode('.', $image_name); |
36 | - $fileParts[count($fileParts) - 2] = $fileParts[count($fileParts) - 2] . '_cropped_' . time(); |
|
36 | + $fileParts[ count($fileParts) - 2 ] = $fileParts[ count($fileParts) - 2 ] . '_cropped_' . time(); |
|
37 | 37 | $crop_path = $this->lfm->setName(implode('.', $fileParts))->path('absolute'); |
38 | 38 | } |
39 | 39 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | return parent::error('rename'); |
34 | 34 | } |
35 | 35 | |
36 | - if (! $is_directory) { |
|
36 | + if (!$is_directory) { |
|
37 | 37 | $extension = $old_file->extension(); |
38 | 38 | if ($extension) { |
39 | 39 | $new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function getDelete() |
16 | 16 | { |
17 | 17 | $item_names = request('items'); |
18 | - $errors = []; |
|
18 | + $errors = [ ]; |
|
19 | 19 | |
20 | 20 | foreach ($item_names as $name_to_delete) { |
21 | 21 | $file_to_delete = $this->lfm->pretty($name_to_delete); |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | continue; |
29 | 29 | } |
30 | 30 | |
31 | - if (! $this->lfm->setName($name_to_delete)->exists()) { |
|
32 | - array_push($errors, parent::error('folder-not-found', ['folder' => $file_path])); |
|
31 | + if (!$this->lfm->setName($name_to_delete)->exists()) { |
|
32 | + array_push($errors, parent::error('folder-not-found', [ 'folder' => $file_path ])); |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | 36 | if ($this->lfm->setName($name_to_delete)->isDirectory()) { |
37 | - if (! $this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
37 | + if (!$this->lfm->setName($name_to_delete)->directoryIsEmpty()) { |
|
38 | 38 | array_push($errors, parent::error('delete-folder')); |
39 | 39 | continue; |
40 | 40 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | private $lfm; |
11 | 11 | private $helper; |
12 | 12 | |
13 | - private $columns = ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']; |
|
14 | - public $attributes = []; |
|
13 | + private $columns = [ 'name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url' ]; |
|
14 | + public $attributes = [ ]; |
|
15 | 15 | |
16 | 16 | public function __construct(LfmPath $lfm, Lfm $helper) |
17 | 17 | { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | { |
24 | 24 | if (!array_key_exists($var_name, $this->attributes)) { |
25 | 25 | $function_name = Str::camel($var_name); |
26 | - $this->attributes[$var_name] = $this->$function_name(); |
|
26 | + $this->attributes[ $var_name ] = $this->$function_name(); |
|
27 | 27 | } |
28 | 28 | |
29 | - return $this->attributes[$var_name]; |
|
29 | + return $this->attributes[ $var_name ]; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function fill() |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | public function isFile() |
57 | 57 | { |
58 | - return ! $this->isDirectory(); |
|
58 | + return !$this->isDirectory(); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - if (in_array($this->mimeType(), ['image/gif', 'image/svg+xml'])) { |
|
182 | + if (in_array($this->mimeType(), [ 'image/gif', 'image/svg+xml' ])) { |
|
183 | 183 | return false; |
184 | 184 | } |
185 | 185 | |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function humanFilesize($bytes, $decimals = 2) |
202 | 202 | { |
203 | - $size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; |
|
203 | + $size = [ 'B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ]; |
|
204 | 204 | $factor = floor((strlen($bytes) - 1) / 3); |
205 | 205 | |
206 | - return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[$factor]); |
|
206 | + return sprintf("%.{$decimals}f %s", $bytes / pow(1024, $factor), @$size[ $factor ]); |
|
207 | 207 | } |
208 | 208 | } |