Completed
Push — master ( 72430f...dafba8 )
by Jonathan
04:56
created

Sharpen   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 35
ccs 12
cts 18
cp 0.6667
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
A getSharpen() 0 12 4
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
7
/**
8
 * @property string $sharp
9
 */
10
class Sharpen extends BaseManipulator
11
{
12
    /**
13
     * Perform sharpen image manipulation.
14
     * @param  Image $image The source image.
15
     * @return Image The manipulated image.
16
     */
17 2
    public function run(Image $image)
18
    {
19 2
        $sharpen = $this->getSharpen();
20
21 2
        if ($sharpen !== null) {
22 2
            $image->sharpen($sharpen);
23 2
        }
24
25 2
        return $image;
26
    }
27
28
    /**
29
     * Resolve sharpen amount.
30
     * @return string The resolved sharpen amount.
31
     */
32 4
    public function getSharpen()
33
    {
34 4
        if (!is_numeric($this->sharp)) {
35 2
            return;
36
        }
37
38 4
        if ($this->sharp < 0 or $this->sharp > 100) {
39 2
            return;
40
        }
41
42 4
        return (int) $this->sharp;
43
    }
44
}
45