Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Polaroid
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
4
 perform
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Karla ImageMagick wrapper library
5 *
6 * PHP Version 8.0<
7 *
8 * @category Utility
9 * @author   Johannes Skov Frandsen <jsf@greenoak.dk>
10 * @license  http://www.opensource.org/licenses/mit-license.php MIT
11 * @link     https://github.com/localgod/karla Karla
12 * @since    2013-05-26
13 */
14
15declare(strict_types=1);
16
17namespace Karla\Action;
18
19use Karla\Query;
20use Karla\Action;
21
22/**
23 * Class for handeling polaroid action
24 *
25 * @category Utility
26 * @author   Johannes Skov Frandsen <jsf@greenoak.dk>
27 * @license  http://www.opensource.org/licenses/mit-license.php MIT
28 * @link     https://github.com/localgod/karla Karla
29 */
30class Polaroid implements Action
31{
32    /**
33     * Angle
34     *
35     * @var integer
36     */
37    private int $angle;
38
39    /**
40     * Construct a new polaroid action
41     *
42     * @param integer $angle
43     *            Angle
44     *
45     * @throws \InvalidArgumentException If the supplied angle is not an integer between 0 and 360.
46     */
47    public function __construct(int $angle)
48    {
49        if (! is_numeric($angle) || $angle > 360 || $angle < 0) {
50            $message = 'The supplied angle (' . $angle . ') must be an integer between 0 and 360';
51            throw new \InvalidArgumentException($message);
52        }
53        $this->angle = (int) $angle;
54    }
55
56    /**
57     * (non-PHPdoc)
58     *
59     * @param Query $query
60     *            The query to add the action to
61     * @return Query
62     * @see Action::perform()
63     */
64    public function perform(Query $query): Query
65    {
66        $query->notWith('polaroid', Query::ARGUMENT_TYPE_INPUT);
67        $query->setInputOption(" -polaroid " . $this->angle . '');
68
69        return $query;
70    }
71}