diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..247a09c --- /dev/null +++ b/.styleci.yml @@ -0,0 +1 @@ +preset: psr2 diff --git a/composer.json b/composer.json index 9f4b77f..223773f 100644 --- a/composer.json +++ b/composer.json @@ -16,12 +16,13 @@ }, "autoload": { "psr-4": { - "Jens\\ImageConverter\\": "src/" - } + "ImageConverter\\": "src/" + }, + "files": ["src/helper.php"] }, "autoload-dev": { "psr-4": { - "Jens\\ImageConverter\\Tests\\": "test/" + "ImageConverter\\Tests\\": "test/" } }, "require-dev": { diff --git a/src/ImageConverter.php b/src/ImageConverter.php index 389d8c2..1b6a1c4 100644 --- a/src/ImageConverter.php +++ b/src/ImageConverter.php @@ -86,8 +86,8 @@ private function saveImage($to, $image, $quality) } - if(isset($quality) && !is_int($quality)) { - throw new \InvalidArgumentException(sprintf('The %s quality has to be an integer', $quality)); + if (isset($quality) && !is_int($quality)) { + throw new \InvalidArgumentException(sprintf('The %s quality has to be an integer', $quality)); } switch ($extension) { @@ -100,7 +100,7 @@ private function saveImage($to, $image, $quality) throw new \InvalidArgumentException(sprintf('The %s quality is out of range', $quality)); } $image = imagejpeg($image, $to, $quality); - break; + break; case 'png': if ($quality < -1 && $quality > 9) { throw new \InvalidArgumentException(sprintf('The %s quality is out of range', $quality)); @@ -169,17 +169,3 @@ private function makeDirectory($to) return $result; } } - -/** - * Helper function - * - * @param string $from - * @param string $to - * - * @return resource - * @throws \InvalidArgumentException - */ -function convert($from, $to, $quality = null) { - $converter = new ImageConverter(); - return $converter->convert($from, $to, $quality); -} \ No newline at end of file diff --git a/src/helper.php b/src/helper.php new file mode 100644 index 0000000..e0d08c7 --- /dev/null +++ b/src/helper.php @@ -0,0 +1,18 @@ +convert($from, $to, $quality); +} diff --git a/tests/ImageConverterTest.php b/tests/ImageConverterTest.php index 5afebcd..a1634e5 100644 --- a/tests/ImageConverterTest.php +++ b/tests/ImageConverterTest.php @@ -1,8 +1,8 @@