Filter   A
last analyzed

↳ Parent: Project

Coupling/Cohesion

Components 1
Dependencies 2

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 47
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 3
A runGreyscaleFilter() 0 4 1
A runSepiaFilter() 0 11 1
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
7
/**
8
 * @property string $filt
9
 */
10
class Filter extends BaseManipulator
11
{
12
    /**
13
     * Perform filter image manipulation.
14
     * @param  Image $image The source image.
15
     * @return Image The manipulated image.
16
     */
17 3
    public function run(Image $image)
18
    {
19 3
        if ($this->filt === 'greyscale') {
20 3
            return $this->runGreyscaleFilter($image);
21
        }
22
23 3
        if ($this->filt === 'sepia') {
24 3
            return $this->runSepiaFilter($image);
25
        }
26
27 3
        return $image;
28
    }
29
30
    /**
31
     * Perform greyscale manipulation.
32
     * @param  Image $image The source image.
33
     * @return Image The manipulated image.
34
     */
35 6
    public function runGreyscaleFilter(Image $image)
36
    {
37 6
        return $image->greyscale();
38
    }
39
40
    /**
41
     * Perform sepia manipulation.
42
     * @param  Image $image The source image.
43
     * @return Image The manipulated image.
44
     */
45 6
    public function runSepiaFilter(Image $image)
46
    {
47 6
        $image->greyscale();
48 6
        $image->brightness(-10);
49 6
        $image->contrast(10);
50 6
        $image->colorize(38, 27, 12);
51 6
        $image->brightness(-10);
52 6
        $image->contrast(10);
53
54 6
        return $image;
55
    }
56
}
57