Background   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 24
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 16 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 background image manipulation.
15
     * @param  Image $image The source image.
16
     * @return Image The manipulated image.
17
     */
18
    public function run(Image $image)
19
    {
20
        if (is_null($this->bg)) {
21
            return $image;
22
        }
23
24
        $color = (new Color($this->bg))->formatted();
25
26
        if ($color) {
27
            $new = $image->getDriver()->newImage($image->width(), $image->height(), $color);
28
            $new->mime = $image->mime;
29
            $image = $new->insert($image, 'top-left', 0, 0);
30
        }
31
32
        return $image;
33
    }
34
}
35