Image_Transform_Driver_Imagick2   B
last analyzed

Complexity

Total Complexity 45

Size/Duplication

Total Lines 328
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 96
dl 0
loc 328
rs 8.8
c 1
b 0
f 0
wmc 45

14 Methods

Rating   Name   Duplication   Size   Complexity  
A Image_Transform_Driver_Imagick2() 0 3 1
A addText() 0 28 5
A gamma() 0 7 2
A raiseError() 0 7 2
A crop() 0 16 3
A flip() 0 7 2
A load() 0 18 4
A mirror() 0 7 2
A rotate() 0 13 3
A __construct() 0 6 2
B display() 0 21 7
B save() 0 23 8
A _resize() 0 10 2
A free() 0 6 2

How to fix   Complexity   

Complex Class

Complex classes like Image_Transform_Driver_Imagick2 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Image_Transform_Driver_Imagick2, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/* vim: set expandtab tabstop=4 shiftwidth=4: */
4
5
/**
6
 * imagick PECL extension implementation for Image_Transform package
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * LICENSE: This source file is subject to version 3.0 of the PHP license
11
 * that is available through the world-wide-web at the following URI:
12
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
13
 * the PHP License and are unable to obtain it through the web, please
14
 * send a note to [email protected] so we can mail you a copy immediately.
15
 *
16
 * @category   Image
17
 * @package    Image_Transform
18
 * @subpackage Image_Transform_Driver_Imagick2
19
 * @author     Alan Knowles <[email protected]>
20
 * @author     Peter Bowyer <[email protected]>
21
 * @author     Philippe Jausions <[email protected]>
22
 * @copyright  2002-2005 The PHP Group
23
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
24
 * @version    CVS: $Id: Imagick2.php 266907 2008-10-01 21:10:50Z dufuz $
25
 * @link       http://pear.php.net/package/Image_Transform
26
 */
27
28
//require_once __DIR__ . '/Image/Transform.php';
29
require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/pear/Image/Image/Transform.php';
30
31
/**
32
 * imagick PECL extension implementation for Image_Transform package
33
 *
34
 * WARNING: For version < 2.0 of the extension. For version 2.0 and up use
35
 * Imagick3 driver instead
36
 *
37
 * @category   Image
38
 * @package    Image_Transform
39
 * @subpackage Image_Transform_Driver_Imagick2
40
 * @author     Alan Knowles <[email protected]>
41
 * @author     Peter Bowyer <[email protected]>
42
 * @author     Philippe Jausions <[email protected]>
43
 * @copyright  2002-2005 The PHP Group
44
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
45
 * @version    Release: @package_version@
46
 * @link       http://pear.php.net/package/Image_Transform
47
 * @since      PHP 4.0
48
 */
49
class Image_Transform_Driver_Imagick2 extends Image_Transform
50
{
51
    /**
52
     * Handler of the imagick image ressource
53
     * @var array
54
     */
55
    public $imageHandle = null;
56
    /**
57
     * Handler of the image ressource before
58
     * the last transformation
59
     * @var array
60
     */
61
    public $oldImage;
62
63
    /**
64
     * @see __construct()
65
     */
66
    public function Image_Transform_Driver_Imagick2()
67
    {
68
        $this->__construct();
69
    }
70
71
    // End Image_Transform_Driver_Imagick2
72
73
    /**
74
     * @see http://www.imagemagick.org/www/formats.html
75
     */
76
    public function __construct()
77
    {
78
        if (PEAR::loadExtension('imagick')) {
79
            require_once __DIR__ . '/Image/Transform/Driver/Imagick/ImageTypes.php';
80
        } else {
81
            $this->isError(PEAR::raiseError('Couldn\'t find the imagick extension.', IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
0 ignored issues
show
Bug introduced by
The method raiseError() does not exist on PEAR. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
            $this->isError(PEAR::/** @scrutinizer ignore-call */ raiseError('Couldn\'t find the imagick extension.', IMAGE_TRANSFORM_ERROR_UNSUPPORTED));
Loading history...
82
        }
83
    }
84
85
    /**
86
     * Loads an image
87
     *
88
     * @param string $image filename
89
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
90
     * @access public
91
     */
92
    public function load($image)
93
    {
94
        if (!($this->imageHandle = imagick_readimage($image))) {
0 ignored issues
show
Bug introduced by
The function imagick_readimage was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

94
        if (!($this->imageHandle = /** @scrutinizer ignore-call */ imagick_readimage($image))) {
Loading history...
95
            $this->free();
96
97
            return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...AGE_TRANSFORM_ERROR_IO) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
98
        }
99
        if (imagick_iserror($this->imageHandle)) {
0 ignored issues
show
Bug introduced by
The function imagick_iserror was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
        if (/** @scrutinizer ignore-call */ imagick_iserror($this->imageHandle)) {
Loading history...
100
            return $this->raiseError('Couldn\'t load image.', IMAGE_TRANSFORM_ERROR_IO);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...AGE_TRANSFORM_ERROR_IO) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
101
        }
102
103
        $this->image = $image;
104
        $result      = $this->_get_image_details($image);
105
        if (PEAR::isError($result)) {
106
            return $result;
107
        }
108
109
        return true;
110
    }
111
112
    // End load
113
114
    /**
115
     * Resize Action
116
     *
117
     * @param int   $new_x   New width
118
     * @param int   $new_y   New height
119
     * @param mixed $options Optional parameters
120
     *
121
     * @return bool|PEAR_Error TRUE or PEAR_Error object on error
122
     * @access protected
123
     */
124
    public function _resize($new_x, $new_y, $options = null)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

124
    public function _resize($new_x, $new_y, /** @scrutinizer ignore-unused */ $options = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
125
    {
126
        if (!imagick_resize($this->imageHandle, $new_x, $new_y, IMAGICK_FILTER_UNKNOWN, 1, '!')) {
0 ignored issues
show
Bug introduced by
The constant IMAGICK_FILTER_UNKNOWN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The function imagick_resize was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

126
        if (!/** @scrutinizer ignore-call */ imagick_resize($this->imageHandle, $new_x, $new_y, IMAGICK_FILTER_UNKNOWN, 1, '!')) {
Loading history...
127
            return $this->raiseError('Couldn\'t resize image.', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
128
        }
129
130
        $this->new_x = $new_x;
131
        $this->new_y = $new_y;
132
133
        return true;
134
    }
135
136
    // End resize
137
138
    /**
139
     * Rotates the current image
140
     * Note: color mask are currently not supported
141
     *
142
     * @param      $angle
143
     * @param null $options
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $options is correct as it would always require null to be passed?
Loading history...
144
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
145
     * @access public
146
     */
147
    public function rotate($angle, $options = null)
148
    {
149
        if (0 == ($angle % 360)) {
150
            return true;
151
        }
152
        if (!imagick_rotate($this->imageHandle, $angle)) {
0 ignored issues
show
Bug introduced by
The function imagick_rotate was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

152
        if (!/** @scrutinizer ignore-call */ imagick_rotate($this->imageHandle, $angle)) {
Loading history...
153
            return $this->raiseError('Cannot create a new imagick image for the rotation.', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
154
        }
155
156
        $this->new_x = imagick_getwidth($this->imageHandle);
0 ignored issues
show
Bug introduced by
The function imagick_getwidth was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

156
        $this->new_x = /** @scrutinizer ignore-call */ imagick_getwidth($this->imageHandle);
Loading history...
157
        $this->new_y = imagick_getheight($this->imageHandle);
0 ignored issues
show
Bug introduced by
The function imagick_getheight was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

157
        $this->new_y = /** @scrutinizer ignore-call */ imagick_getheight($this->imageHandle);
Loading history...
158
159
        return true;
160
    }
161
162
    // End rotate
163
164
    /**
165
     * addText
166
     *
167
     * @param mixed $params
168
     *
169
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
170
     * @access public
171
     */
172
    public function addText($params)
173
    {
174
        $this->oldImage = $this->imageHandle;
175
        $params         = array_merge($this->_get_default_text_params(), $params);
176
177
        if (is_array($params['color'])) {
178
            $params['color'] = $this->colorarray2colorhex($params['color']);
179
        } else {
180
            $params['color'] = mb_strtolower($params['color']);
181
        }
182
183
        static $cmds = [
184
            'setfillcolor' => 'color',
185
            'setfontsize'  => 'size',
186
            'setfontface'  => 'font',
187
        ];
188
        imagick_begindraw($this->imageHandle);
0 ignored issues
show
Bug introduced by
The function imagick_begindraw was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

188
        /** @scrutinizer ignore-call */ 
189
        imagick_begindraw($this->imageHandle);
Loading history...
189
190
        foreach ($cmds as $cmd => $v) {
191
            if (!call_user_func('imagick_' . $cmd, $this->imageHandle, $params[$v])) {
192
                return $this->raiseError("Problem with adding Text::{$v} = {$params[$v]}", IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
193
            }
194
        }
195
        if (!imagick_drawannotation($this->imageHandle, $params['x'], $params['y'], $params['text'])) {
0 ignored issues
show
Bug introduced by
The function imagick_drawannotation was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

195
        if (!/** @scrutinizer ignore-call */ imagick_drawannotation($this->imageHandle, $params['x'], $params['y'], $params['text'])) {
Loading history...
196
            return $this->raiseError('Problem with adding Text', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
197
        }
198
199
        return true;
200
    }
201
202
    // End addText
203
204
    /**
205
     * Saves the image to a file
206
     *
207
     * @param string $filename the name of the file to write to
208
     * @param string $type
209
     * @param null   $quality
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $quality is correct as it would always require null to be passed?
Loading history...
210
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
211
     * @access public
212
     */
213
    public function save($filename, $type = '', $quality = null)
214
    {
215
        $options = is_array($quality) ? $quality : [];
0 ignored issues
show
introduced by
The condition is_array($quality) is always false.
Loading history...
216
        if (is_numeric($quality)) {
0 ignored issues
show
introduced by
The condition is_numeric($quality) is always false.
Loading history...
217
            $options['quality'] = $quality;
218
        }
219
        $quality = $this->_getOption('quality', $options, 75);
220
        imagick_setcompressionquality($this->imageHandle, $quality);
0 ignored issues
show
Bug introduced by
The function imagick_setcompressionquality was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

220
        /** @scrutinizer ignore-call */ 
221
        imagick_setcompressionquality($this->imageHandle, $quality);
Loading history...
221
222
        if ($type && strcasecmp($type, $this->type)
223
            && !imagick_convert($this->imageHandle, $type)) {
0 ignored issues
show
Bug introduced by
The function imagick_convert was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

223
            && !/** @scrutinizer ignore-call */ imagick_convert($this->imageHandle, $type)) {
Loading history...
224
            return $this->raiseError('Couldn\'t save image to file (conversion failed).', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
225
        }
226
227
        if (!imagick_write($this->imageHandle, $filename)) {
0 ignored issues
show
Bug introduced by
The function imagick_write was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

227
        if (!/** @scrutinizer ignore-call */ imagick_write($this->imageHandle, $filename)) {
Loading history...
228
            return $this->raiseError('Couldn\'t save image to file.', IMAGE_TRANSFORM_ERROR_IO);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...AGE_TRANSFORM_ERROR_IO) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
229
        }
230
231
        if (!$this->keep_settings_on_save) {
232
            $this->free();
233
        }
234
235
        return true;
236
    }
237
238
    // End save
239
240
    /**
241
     * Displays image without saving and lose changes
242
     *
243
     * This method adds the Content-type HTTP header
244
     *
245
     * @param mixed      $type
246
     * @param null|mixed $quality
247
     *
248
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
249
     * @access public
250
     */
251
    public function display($type = '', $quality = null)
252
    {
253
        $options = is_array($quality) ? $quality : [];
254
        if (is_numeric($quality)) {
255
            $options['quality'] = $quality;
256
        }
257
        $quality = $this->_getOption('quality', $options, 75);
258
        imagick_setcompressionquality($this->imageHandle, $quality);
0 ignored issues
show
Bug introduced by
The function imagick_setcompressionquality was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

258
        /** @scrutinizer ignore-call */ 
259
        imagick_setcompressionquality($this->imageHandle, $quality);
Loading history...
259
260
        if ($type && strcasecmp($type, $this->type)
261
            && !imagick_convert($this->imageHandle, $type)) {
0 ignored issues
show
Bug introduced by
The function imagick_convert was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

261
            && !/** @scrutinizer ignore-call */ imagick_convert($this->imageHandle, $type)) {
Loading history...
262
            return $this->raiseError('Couldn\'t save image to file (conversion failed).', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
263
        }
264
        if (!($image = imagick_image2blob($this->imageHandle))) {
0 ignored issues
show
Bug introduced by
The function imagick_image2blob was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

264
        if (!($image = /** @scrutinizer ignore-call */ imagick_image2blob($this->imageHandle))) {
Loading history...
265
            return $this->raiseError('Couldn\'t display image.', IMAGE_TRANSFORM_ERROR_IO);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...AGE_TRANSFORM_ERROR_IO) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
266
        }
267
        header('Content-type: ' . imagick_getmimetype($this->imageHandle));
0 ignored issues
show
Bug introduced by
The function imagick_getmimetype was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

267
        header('Content-type: ' . /** @scrutinizer ignore-call */ imagick_getmimetype($this->imageHandle));
Loading history...
268
        echo $image;
269
        $this->free();
270
271
        return true;
272
    }
273
274
    /**
275
     * Adjusts the image gamma
276
     *
277
     * @param float $outputgamma
278
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
279
     * @access public
280
     */
281
    public function gamma($outputgamma = 1.0)
282
    {
283
        if (1.0 != $outputgamma) {
284
            imagick_gamma($this->imageHandle, $outputgamma);
0 ignored issues
show
Bug introduced by
The function imagick_gamma was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

284
            /** @scrutinizer ignore-call */ 
285
            imagick_gamma($this->imageHandle, $outputgamma);
Loading history...
285
        }
286
287
        return true;
288
    }
289
290
    /**
291
     * Crops the image
292
     *
293
     * @param mixed $width
294
     * @param mixed $height
295
     * @param mixed $x
296
     * @param mixed $y
297
     *
298
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
299
     * @access public
300
     */
301
    public function crop($width, $height, $x = 0, $y = 0)
302
    {
303
        // Sanity check
304
        if (!$this->intersects($width, $height, $x, $y)) {
305
            return PEAR::raiseError('Nothing to crop', IMAGE_TRANSFORM_ERROR_OUTOFBOUND);
306
        }
307
        if (!imagick_crop($this->imageHandle, $x, $y, $width, $height)) {
0 ignored issues
show
Bug introduced by
The function imagick_crop was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

307
        if (!/** @scrutinizer ignore-call */ imagick_crop($this->imageHandle, $x, $y, $width, $height)) {
Loading history...
308
            return $this->raiseError('Couldn\'t crop image.', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
309
        }
310
311
        // I think that setting img_x/y is wrong, but scaleByLength() & friends
312
        // mess up the aspect after a crop otherwise.
313
        $this->new_x = $width;
314
        $this->new_y = $height;
315
316
        return true;
317
    }
318
319
    /**
320
     * Horizontal mirroring
321
     *
322
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
323
     * @access public
324
     */
325
    public function mirror()
326
    {
327
        if (!imagick_flop($this->imageHandle)) {
0 ignored issues
show
Bug introduced by
The function imagick_flop was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

327
        if (!/** @scrutinizer ignore-call */ imagick_flop($this->imageHandle)) {
Loading history...
328
            return $this->raiseError('Couldn\'t mirror the image.', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
329
        }
330
331
        return true;
332
    }
333
334
    /**
335
     * Vertical mirroring
336
     *
337
     * @return bool|PEAR_Error TRUE or a PEAR_Error object on error
338
     * @access public
339
     */
340
    public function flip()
341
    {
342
        if (!imagick_flip($this->imageHandle)) {
0 ignored issues
show
Bug introduced by
The function imagick_flip was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

342
        if (!/** @scrutinizer ignore-call */ imagick_flip($this->imageHandle)) {
Loading history...
343
            return $this->raiseError('Couldn\'t flip the image.', IMAGE_TRANSFORM_ERROR_FAILED);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->raiseError...TRANSFORM_ERROR_FAILED) returns the type PEAR which is incompatible with the documented return type PEAR_Error|boolean.
Loading history...
344
        }
345
346
        return true;
347
    }
348
349
    /**
350
     * Destroy image handle
351
     *
352
     * @access public
353
     */
354
    public function free()
355
    {
356
        if (is_resource($this->imageHandle)) {
0 ignored issues
show
introduced by
The condition is_resource($this->imageHandle) is always false.
Loading history...
357
            imagick_destroyhandle($this->imageHandle);
0 ignored issues
show
Bug introduced by
The function imagick_destroyhandle was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

357
            /** @scrutinizer ignore-call */ 
358
            imagick_destroyhandle($this->imageHandle);
Loading history...
358
        }
359
        $this->imageHandle = null;
360
    }
361
362
    /**
363
     * RaiseError Method - shows imagick Raw errors.
364
     *
365
     * @param string $message message = prefixed message..
366
     * @param int    $code    error code
367
     * @return PEAR error object
368
     * @access protected
369
     */
370
    public function raiseError($message, $code = 0)
371
    {
372
        if (is_resource($this->imageHandle)) {
0 ignored issues
show
introduced by
The condition is_resource($this->imageHandle) is always false.
Loading history...
373
            $message .= "\nReason: " . imagick_failedreason($this->imageHandle) . "\nDescription: " . imagick_faileddescription($this->imageHandle);
0 ignored issues
show
Bug introduced by
The function imagick_failedreason was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

373
            $message .= "\nReason: " . /** @scrutinizer ignore-call */ imagick_failedreason($this->imageHandle) . "\nDescription: " . imagick_faileddescription($this->imageHandle);
Loading history...
Bug introduced by
The function imagick_faileddescription was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

373
            $message .= "\nReason: " . imagick_failedreason($this->imageHandle) . "\nDescription: " . /** @scrutinizer ignore-call */ imagick_faileddescription($this->imageHandle);
Loading history...
374
        }
375
376
        return PEAR::raiseError($message, $code);
377
    }
378
} // End class Image_Transform_Driver_Imagick2
379