Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Colorspace | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
perform | |
100.00% |
3 / 3 |
|
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 | |
15 | declare(strict_types=1); |
16 | |
17 | namespace Karla\Action; |
18 | |
19 | use Karla\Program; |
20 | use Karla\Query; |
21 | use Karla\Action; |
22 | use Karla\Support; |
23 | |
24 | /** |
25 | * Class for handeling colorspace action |
26 | * |
27 | * @category Utility |
28 | * @author Johannes Skov Frandsen <jsf@greenoak.dk> |
29 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
30 | * @link https://github.com/localgod/karla Karla |
31 | */ |
32 | class Colorspace implements Action |
33 | { |
34 | /** |
35 | * Colorspace |
36 | * |
37 | * @var string |
38 | */ |
39 | private string $colorspace; |
40 | |
41 | /** |
42 | * Construct a new size action |
43 | * |
44 | * @param \Karla\Program $program |
45 | * The program to use |
46 | * @param string $colorspace |
47 | * Colorspace |
48 | * |
49 | * @throws \InvalidArgumentException If he supplied colorspace is not supported by imagemagick. |
50 | */ |
51 | public function __construct(Program $program, string $colorspace) |
52 | { |
53 | if (! Support::colorSpace($program, $colorspace)) { |
54 | $message = 'The supplied colorspace (' . $colorspace . ') is not supported by imagemagick'; |
55 | throw new \InvalidArgumentException($message); |
56 | } |
57 | $this->colorspace = $colorspace; |
58 | } |
59 | |
60 | /** |
61 | * (non-PHPdoc) |
62 | * |
63 | * @param Query $query |
64 | * The query to add the action to |
65 | * @return Query |
66 | * @see Action::perform() |
67 | */ |
68 | public function perform(Query $query): Query |
69 | { |
70 | $query->notWith('colorspace', Query::ARGUMENT_TYPE_OUTPUT); |
71 | $query->setOutputOption(" -colorspace " . $this->colorspace . ' '); |
72 | |
73 | return $query; |
74 | } |
75 | } |