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 43.75%

Importance

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

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 2
    public function run(Image $image)
18
    {
19 2
        if ($flip = $this->getFlip()) {
20 2
            if ($flip === 'both') {
21
                return $image->flip('h')->flip('v');
22
            }
23
24 2
            return $image->flip($flip);
25
        }
26
27
        return $image;
28
    }
29
30
    /**
31
     * Resolve flip.
32
     * @return string The resolved flip.
33
     */
34 4
    public function getFlip()
35
    {
36 4
        if (in_array($this->flip, ['h', 'v', 'both'], true)) {
37 4
            return $this->flip;
38
        }
39
    }
40
}
41