Flip::getFlip()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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