ImageException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getImage() 0 11 2
1
<?php
2
3
namespace Imagecow;
4
5
/**
6
 * Exception class to manage the image errors.
7
 */
8
class ImageException extends \Exception
9
{
10
    /**
11
     * Generate an image with the message printed. Use always the Gd library.
12
     *
13
     * @param int $width  Width of the image
14
     * @param int $height Height of the image
15
     *
16
     * @return Image
17
     */
18
    public function getImage($width = 400, $height = 400)
19
    {
20
        $image = imagecreatetruecolor($width, $height);
21
        $textColor = imagecolorallocate($image, 255, 255, 255);
22
23
        foreach (str_split($this->getMessage(), intval($width / 10)) as $line => $text) {
24
            imagestring($image, 5, 10, (($line + 1) * 18), $text, $textColor);
25
        }
26
27
        return new Image(new Libs\Gd($image));
28
    }
29
}
30