Orientation   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 2

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 31
ccs 9
cts 15
cp 0.6
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
A getOrientation() 0 8 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 2
    public function run(Image $image)
18
    {
19 2
        $orientation = $this->getOrientation();
20
21 2
        if ($orientation === 'auto') {
22 2
            return $image->orientate();
23
        }
24
25 2
        return $image->rotate($orientation);
26
    }
27
28
    /**
29
     * Resolve orientation.
30
     * @return string The resolved orientation.
31
     */
32 4
    public function getOrientation()
33
    {
34 4
        if (in_array($this->or, ['auto', '0', '90', '180', '270'], true)) {
35 4
            return $this->or;
36
        }
37
38 2
        return 'auto';
39
    }
40
}
41