Skip to content

Commit

Permalink
Merge pull request #7 from amirHossein5/analysis-OMEpN4
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
amirHossein5 authored Mar 21, 2022
2 parents 2afca87 + ef7c012 commit 81f6584
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Removeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public function rm($image, $removeIndex = null): bool
if (!$removeIndex) {
if (is_string($image)) {
$this->unlinkImagePath($image);

return $this->wasRecentlyRemoved;
} elseif (is_string($image['index'])) {
$this->unlinkImagePath($image['index']);

return $this->wasRecentlyRemoved;
} elseif (is_array($image['index'])) {
$this->unsetImagePaths(array_values($image['index']));
Expand All @@ -36,6 +38,7 @@ public function rm($image, $removeIndex = null): bool

if (is_string($image[$removeIndex])) {
$this->unlinkImagePath($image[$removeIndex]);

return $this->wasRecentlyRemoved;
} elseif (is_array($image[$removeIndex])) {
$this->unsetImagePaths(array_values($image[$removeIndex]));
Expand All @@ -54,6 +57,7 @@ public function rm($image, $removeIndex = null): bool
* remove the given image paths.
*
* @param array $paths
*
* @return void
*/
private function unsetImagePaths(array $paths): void
Expand All @@ -76,6 +80,7 @@ private function unsetImagePaths(array $paths): void
* remove the given image path.
*
* @param string $path
*
* @return void
*/
private function unlinkImagePath(string $path): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ public function test_rm_wont_throw_exception_when_path_is_unlocatable()
->setExclusiveDirectory('post')
->autoResize()
->save();

Image::rm($image);
$this->assertTrue(Image::wasRecentlyRemoved());
Image::rm($image);
Expand Down Expand Up @@ -1289,7 +1289,7 @@ public function test_rm_wont_throw_exception_when_path_is_unlocatable()
->save(false, function ($image) {
return $image->imagePath;
});

Image::disk('storage')->rm($image);
$this->assertTrue(Image::wasRecentlyRemoved());
Image::disk('storage')->rm($image);
Expand Down

0 comments on commit 81f6584

Please sign in to comment.