From 86d795d0fcc97b7ce5f1a727282cdb1117d59067 Mon Sep 17 00:00:00 2001 From: Ekin Karadeniz Date: Sat, 7 Nov 2020 00:40:12 +0300 Subject: [PATCH] unnecessary --- src/Uploader.php | 11 +++++------ tests/FileNameTest.php | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Uploader.php b/src/Uploader.php index 9f69745..481d545 100644 --- a/src/Uploader.php +++ b/src/Uploader.php @@ -412,15 +412,13 @@ public function check() $image_dimensions = getimagesize($this->file["tmp_name"]); if (!$image_dimensions) { $this->error = self::ERR_NOT_AN_IMAGE; - } - if ($this->error === null && $this->max_image_dimensions !== null) { + } else if ($this->max_image_dimensions !== null) { for ($i = 0; $i <= 1; $i++) { if (isset($this->max_image_dimensions[$i]) && is_numeric($this->max_image_dimensions[$i]) && $image_dimensions[$i] > $this->max_image_dimensions[$i]) { $this->error = self::ERR_MAX_DIMENSION; } } - } - if ($this->error === null && $this->min_image_dimensions !== null) { + } else if ($this->min_image_dimensions !== null) { for ($i = 0; $i <= 1; $i++) { if (isset($this->min_image_dimensions[$i]) && is_numeric($this->min_image_dimensions[$i]) && $image_dimensions[$i] < $this->min_image_dimensions[$i]) { $this->error = self::ERR_MIN_DIMENSION; @@ -461,7 +459,7 @@ public function upload($copy_file = false) @mkdir($upload_dir, 0777, true); } $filepath = $this->get_path(); - if ($this->override === false && $this->encrypt_name === false && file_exists($filepath)) { + if ($this->override === false && file_exists($filepath)) { $number = 2; $filename = pathinfo($filepath, PATHINFO_FILENAME); do { @@ -580,7 +578,8 @@ public static function create_temp_file($source, $mime_map = []) if (isset($mime_map[$mime])) { $ext = $mime_map[$mime]; } else { - $ext = array_pop(explode("/", $mime)); + $arr = explode("/", $mime); + $ext = end($arr); } register_shutdown_function(function() use ($temp) { diff --git a/tests/FileNameTest.php b/tests/FileNameTest.php index 2f20742..730360b 100644 --- a/tests/FileNameTest.php +++ b/tests/FileNameTest.php @@ -42,6 +42,7 @@ public function testName5() $upload->encrypt_name(); $this->assertNotEquals($upload->get_name(), "foo.json"); + $this->assertEquals($upload->encrypt_name, false); // Because it's setting to 'true' once } public function testName6()