Skip to content

Commit 8159436

Browse files
authored
Merge pull request #11 from pratiksh404/analysis-lKNo5k
Apply fixes from StyleCI
2 parents eefacb8 + 8de5aae commit 8159436

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

src/Traits/Thumbnail.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
use Carbon\Carbon;
66
use Illuminate\Support\Facades\File;
7-
use Intervention\Image\Facades\Image as Image;
7+
use Intervention\Image\Facades\Image;
88

99
trait Thumbnail
1010
{
1111
public function makeThumbnail($fieldname = 'image', $custom = [])
1212
{
13-
if (!empty(request()->$fieldname) || $custom['image']) {
13+
if (! empty(request()->$fieldname) || $custom['image']) {
1414
/* ------------------------------------------------------------------- */
1515

1616
$image_file = $custom['image'] ?? request()->file($fieldname); // Retriving Image File
@@ -29,7 +29,7 @@ public function makeThumbnail($fieldname = 'image', $custom = [])
2929
if ($thumbnails) {
3030
/* -----------------------------------------Custom Thumbnails------------------------------------------------- */
3131
$this->makeCustomThumbnails($image_file, $imageStoreNameOnly, $extension, $storage, $thumbnails);
32-
/* -------------------------------------------------------------------------------------------------- */
32+
/* -------------------------------------------------------------------------------------------------- */
3333
} else {
3434
/* ---------------------------------------Default Thumbnails--------------------------------------- */
3535
$this->makeDefaultThumbnails($image_file, $extension, $imageStoreNameOnly);
@@ -46,14 +46,14 @@ private function makeImg($image_file, $name, $location, $width, $height, $qualit
4646
$img = Image::cache(function ($cached_img) use ($image_file, $width, $height) {
4747
return $cached_img->make($image_file->getRealPath())->fit($width, $height);
4848
}, config('thumbnail.image_cached_time', 10), true); //Storing Thumbnail
49-
$img->save(public_path('storage/' . $image), $quality); //Storing Thumbnail
49+
$img->save(public_path('storage/'.$image), $quality); //Storing Thumbnail
5050
}
5151

5252
// Make Custom Thumbnail
5353
private function makeCustomThumbnails($image_file, $imageStoreNameOnly, $extension, $storage, $thumbnails)
5454
{
5555
foreach ($thumbnails as $thumbnail) {
56-
$customthumbnail = $imageStoreNameOnly . '-' . str_replace('-', '', $thumbnail['thumbnail-name']) . '.' . $extension; // Making Thumbnail Name
56+
$customthumbnail = $imageStoreNameOnly.'-'.str_replace('-', '', $thumbnail['thumbnail-name']).'.'.$extension; // Making Thumbnail Name
5757
$this->makeImg(
5858
$image_file,
5959
$customthumbnail,
@@ -70,10 +70,10 @@ private function makeDefaultThumbnails($image_file, $extension, $imageStoreNameO
7070
{
7171
/* --------------------- Thumbnail Info---------------------------------------- */
7272
//small thumbnail name
73-
$smallthumbnail = $imageStoreNameOnly . '-small' . '.' . $extension; // Making Thumbnail Name
73+
$smallthumbnail = $imageStoreNameOnly.'-small'.'.'.$extension; // Making Thumbnail Name
7474

7575
//medium thumbnail name
76-
$mediumthumbnail = $imageStoreNameOnly . '-medium' . '.' . $extension; // Making Thumbnail Name
76+
$mediumthumbnail = $imageStoreNameOnly.'-medium'.'.'.$extension; // Making Thumbnail Name
7777

7878
// Medium Thumbnail
7979
$this->makeImg(
@@ -103,10 +103,10 @@ private function image_info($image_file)
103103
{
104104
$filenamewithextension = $image_file->getClientOriginalName(); //Retriving Full Image Name
105105
$raw_filename = pathinfo($filenamewithextension, PATHINFO_FILENAME); //Retriving Image Raw Filename only
106-
$filename = $this->validImageName($raw_filename);; // Retrive Filename
106+
$filename = $this->validImageName($raw_filename); // Retrive Filename
107107
$extension = $image_file->getClientOriginalExtension(); //Retriving Image extension
108-
$imageStoreNameOnly = $filename . '-' . time(); //Making Image Store name
109-
$imageStoreName = $filename . '-' . time() . '.' . $extension; //Making Image Store name
108+
$imageStoreNameOnly = $filename.'-'.time(); //Making Image Store name
109+
$imageStoreName = $filename.'-'.time().'.'.$extension; //Making Image Store name
110110

111111
$image_info['filenamewithextension'] = $filenamewithextension;
112112
$image_info['raw_filename'] = $raw_filename;
@@ -131,7 +131,7 @@ public function uploadImage($fieldname = 'image', $custom = [])
131131
$image = Image::cache(function ($cached_img) use ($image_file, $custom) {
132132
return $cached_img->make($image_file->getRealPath())->fit($custom['width'] ?? config('thumbnail.img_width', 1000), $custom['height'] ?? config('thumbnail.img_height', 800)); //Parent Image Interventing
133133
}, config('thumbnail.image_cached_time', 10), true);
134-
$image->save(public_path('storage/' . $this->$fieldname), $custom['quality'] ?? config('thumbnail.image_quality', 80)); // Parent Image Locating Save
134+
$image->save(public_path('storage/'.$this->$fieldname), $custom['quality'] ?? config('thumbnail.image_quality', 80)); // Parent Image Locating Save
135135
}
136136

137137
// Thumbnail Path
@@ -165,21 +165,21 @@ public function imageDetail($fieldname = 'image', $size = null, $byLocation = fa
165165
$image = $byLocation ? ($location ?? $this->$fieldname) : $this->$fieldname; // Search By Field or Location
166166
$path = explode('/', $image);
167167
$extension = \File::extension($image);
168-
$name = basename($image, '.' . $extension);
169-
$image_fullname = isset($size) ? $name . '-' . (string) $size . '.' . $extension : $name . '.' . $extension;
168+
$name = basename($image, '.'.$extension);
169+
$image_fullname = isset($size) ? $name.'-'.(string) $size.'.'.$extension : $name.'.'.$extension;
170170
array_pop($path);
171171
$location = implode('/', $path);
172-
$path = 'storage/' . $location . '/' . $image_fullname;
173-
$image_files = File::files(public_path('storage/' . $location));
172+
$path = 'storage/'.$location.'/'.$image_fullname;
173+
$image_files = File::files(public_path('storage/'.$location));
174174
$images_property = $this->imageProperty($image_files, $name);
175175
$image_detail = [
176176
'image' => $image,
177177
'name' => $name,
178178
'fullname' => $image_fullname,
179179
'extension' => $extension,
180180
'path' => $path,
181-
'directory' => public_path('storage/' . $location),
182-
'location' => public_path('storage/' . $image),
181+
'directory' => public_path('storage/'.$location),
182+
'location' => public_path('storage/'.$image),
183183
'property' => $images_property,
184184
];
185185

@@ -199,7 +199,7 @@ private function imageProperty($image_files, $parent_name)
199199

200200
$image_partition = explode('-', basename($image));
201201
if (isset($image_partition[0]) && isset($image_partition[1])) {
202-
$parent_thumbnail_name = $image_partition[0] . '-' . $image_partition[1];
202+
$parent_thumbnail_name = $image_partition[0].'-'.$image_partition[1];
203203
if ($parent_name == $parent_thumbnail_name) {
204204
$thumbnail_count++;
205205
$thumbnail_exists = $this->imageExists($image);
@@ -221,7 +221,8 @@ private function imageProperty($image_files, $parent_name)
221221
$images_property['size'] = $image->getSize();
222222
$images_property['directory'] = $image->getPath();
223223
$images_property['location'] = $image->getRealPath();
224-
} else { }
224+
} else {
225+
}
225226
}
226227
}
227228

@@ -251,6 +252,6 @@ public function hardDeleteWithParent($fieldname = 'image'): void
251252
// Valid Image Name
252253
private function validImageName($name)
253254
{
254-
return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', '}', '*', '\\', '/', ':' . ';', ',', "'", '"'], '_', trim($name)));
255+
return strtolower(str_replace([' ', '-', '$', '<', '>', '&', '{', '}', '*', '\\', '/', ':'.';', ',', "'", '"'], '_', trim($name)));
255256
}
256257
}

0 commit comments

Comments
 (0)