Flip::run()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
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