ColorizeFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 1
cbo 2
dl 0
loc 30
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A render() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the kaloa/image package.
5
 *
6
 * For full copyright and license information, please view the LICENSE file
7
 * that was distributed with this source code.
8
 */
9
10
namespace Kaloa\Image\Filter;
11
12
use Kaloa\Image\Filter\AbstractFilter;
13
use Kaloa\Image\Image;
14
15
final class ColorizeFilter extends AbstractFilter
16
{
17
    private $red;
18
    private $green;
19
    private $blue;
20
    private $alpha;
21
22
    /**
23
     *
24
     * @param int $red   [-255,255]
25
     * @param int $green [-255,255]
26
     * @param int $blue  [-255,255]
27
     * @param int $alpha [0,127]
28
     */
29 1
    public function __construct($red, $green, $blue, $alpha)
30
    {
31 1
        $this->red   = $red;
32 1
        $this->green = $green;
33 1
        $this->blue  = $blue;
34 1
        $this->alpha = $alpha;
35 1
    }
36
37 1
    public function render(Image $srcImage)
38
    {
39 1
        imagefilter($srcImage->getResource(), IMG_FILTER_COLORIZE, $this->red, $this->green,
40 1
                $this->blue, $this->alpha);
41
42 1
        return $srcImage->getResource();
43
    }
44
}
45