Flip   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 12 3
A getFlip() 0 6 2
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
7
/**
8
 * @property string $flip
9
 */
10
class Flip extends BaseManipulator
11
{
12
    /**
13
     * Perform flip image manipulation.
14
     * @param  Image $image The source image.
15
     * @return Image The manipulated image.
16
     */
17
    public function run(Image $image)
18
    {
19
        if ($flip = $this->getFlip()) {
20
            if ($flip === 'both') {
21
                return $image->flip('h')->flip('v');
22
            }
23
24
            return $image->flip($flip);
25
        }
26
27
        return $image;
28
    }
29
30
    /**
31
     * Resolve flip.
32
     * @return string The resolved flip.
33
     */
34
    public function getFlip()
35
    {
36
        if (in_array($this->flip, ['h', 'v', 'both'], true)) {
37
            return $this->flip;
38
        }
39
    }
40
}
41