Skip to content

Commit 7661adc

Browse files
committed
Replaced general Exception with own ImageResizeException
1 parent 7c51c84 commit 7661adc

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

lib/ImageResize.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Eventviva;
44

5-
use \Exception;
6-
75
/**
86
* PHP class to resize and scale images
97
*/
@@ -46,7 +44,7 @@ class ImageResize
4644
*
4745
* @param string $image_data
4846
* @return ImageResize
49-
* @throws \exception
47+
* @throws ImageResizeException
5048
*/
5149
public static function createFromString($image_data)
5250
{
@@ -59,14 +57,14 @@ public static function createFromString($image_data)
5957
*
6058
* @param string $filename
6159
* @return ImageResize
62-
* @throws \Exception
60+
* @throws ImageResizeException
6361
*/
6462
public function __construct($filename)
6563
{
6664
$image_info = @getimagesize($filename);
6765

6866
if (!$image_info) {
69-
throw new \Exception('Could not read file');
67+
throw new ImageResizeException('Could not read file');
7068
}
7169

7270
list (
@@ -94,12 +92,12 @@ public function __construct($filename)
9492
break;
9593

9694
default:
97-
throw new \Exception('Unsupported image type');
95+
throw new ImageResizeException('Unsupported image type');
9896
break;
9997
}
100-
98+
10199
if (!$this->source_image) {
102-
throw new \Exception('Could not load image');
100+
throw new ImageResizeException('Could not load image');
103101
}
104102

105103
return $this->resize($this->getSourceWidth(), $this->getSourceHeight());
@@ -222,7 +220,7 @@ public function save($filename, $image_type = null, $quality = null, $permission
222220
if ($permissions) {
223221
chmod($filename, $permissions);
224222
}
225-
223+
226224
imagedestroy($dest_image);
227225

228226
return $this;

lib/ImageResizeException.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Eventviva;
4+
5+
use \Exception;
6+
7+
/**
8+
* PHP Exception used in the ImageResize class
9+
*/
10+
class ImageResizeException extends Exception
11+
{
12+
13+
}

0 commit comments

Comments
 (0)