Rotate   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 24
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 3
1
<?php
2
3
namespace yiicod\easyimage\tools;
4
5
use Exception;
6
use Imagine\Image\Color;
7
use Imagine\Image\ManipulatorInterface;
8
use yiicod\easyimage\base\ToolInterface;
9
10
/**
11
 * Class Rotate
12
 * Rotate image tool
13
 *
14
 * @author Virchenko Maksim <[email protected]>
15
 *
16
 * @package yiicod\easyimage\tools
17
 */
18
class Rotate implements ToolInterface
19
{
20
    /**
21
     * Handle image
22
     *
23
     * @param ManipulatorInterface $image
24
     * @param array $params
25
     *
26
     * @return ManipulatorInterface
27
     *
28
     * @throws Exception
29
     */
30
    public static function handle(ManipulatorInterface $image, array $params = []): ManipulatorInterface
31
    {
32
        if (false === isset($params['angle'])) {
33
            throw new Exception('Param "angle" is required for action "Rotate"');
34
        }
35
36
        return $image->rotate(
37
            $params['angle'],
38
            isset($params['background']) ? new Color($params['background']) : null
39
        );
40
    }
41
}
42