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

Orientation::getOrientation()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace League\Glide\Manipulators;
4
5
use Intervention\Image\Image;
6
7
/**
8
 * @property string $or
9
 */
10
class Orientation extends BaseManipulator
11
{
12
    /**
13
     * Perform orientation 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
        $orientation = $this->getOrientation();
20
21 3
        if ($orientation === 'auto') {
22 3
            return $image->orientate();
23
        }
24
25 3
        return $image->rotate($orientation);
26
    }
27
28
    /**
29
     * Resolve orientation.
30
     * @return string The resolved orientation.
31
     */
32 6
    public function getOrientation()
33
    {
34 6
        if (in_array($this->or, ['auto', '0', '90', '180', '270'], true)) {
35 6
            return $this->or;
36
        }
37
38 3
        return 'auto';
39
    }
40
}
41