Completed
Push — master ( fbcc48...388212 )
by Jonathan
02:22
created

Background::run()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 2
Metric Value
c 3
b 0
f 2
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.4286
cc 3
eloc 9
nc 3
nop 1
crap 3
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
use League\Glide\Manipulators\Helpers\Color;
7
8
/**
9
 * @property string $bg
10
 */
11
class Background extends BaseManipulator
12
{
13
    /**
14
     * Perform blur image manipulation.
15
     * @param  Image $image The source image.
16
     * @return Image The manipulated image.
17
     */
18 3
    public function run(Image $image)
19
    {
20 3
        if (is_null($this->bg)) {
21 3
            return;
22
        }
23
24 3
        $color = (new Color($this->bg))->formatted();
25
26 3
        if ($color) {
27 3
            $new = $image->getDriver()->newImage($image->width(), $image->height(), $color);
28 3
            $new->mime = $image->mime;
29 3
            $image = $new->insert($image, 'top-left', 0, 0);
30 2
        }
31
32 3
        return $image;
33
    }
34
}
35