ContrastFilter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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\Image;
13
14
final class ContrastFilter extends AbstractFilter
15
{
16
    private $level;
17
18
    /**
19
     *
20
     * @param int $level [-100, 100] -100 = min contrast, 0 = no change,
21
     *                   +100 = max contrast
22
     */
23 2
    public function __construct($level)
24
    {
25 2
        $this->level = -1 * $level;
26 2
    }
27
28 2
    public function render(Image $srcImage)
29
    {
30 2
        imagefilter($srcImage->getResource(), IMG_FILTER_CONTRAST, $this->level);
31
32 2
        return $srcImage->getResource();
33
    }
34
}
35