Completed
Push — master ( 66d197...72430f )
by Jonathan
03:30
created

Gamma   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
A getGamma() 0 12 4
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
7
/**
8
 * @property string $gam
9
 */
10
class Gamma extends BaseManipulator
11
{
12
    /**
13
     * Perform gamma 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
        $gamma = $this->getGamma();
20
21 3
        if ($gamma) {
22 3
            $image->gamma($gamma);
23 3
        }
24
25 3
        return $image;
26
    }
27
28
    /**
29
     * Resolve gamma amount.
30
     * @return string The resolved gamma amount.
31
     */
32 6
    public function getGamma()
33
    {
34 6
        if (!preg_match('/^[0-9]\.*[0-9]*$/', $this->gam)) {
35 3
            return;
36
        }
37
38 6
        if ($this->gam < 0.1 or $this->gam > 9.99) {
39 3
            return;
40
        }
41
42 6
        return (double) $this->gam;
43
    }
44
}
45