Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
Layers | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
perform | |
100.00% |
2 / 2 |
|
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 layers 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 Layers implements Action |
33 | { |
34 | /** |
35 | * Method |
36 | * |
37 | * @var string |
38 | */ |
39 | private string $method; |
40 | |
41 | /** |
42 | * Contruct new action |
43 | * |
44 | * @param \Karla\Program $program |
45 | * The program to use |
46 | * @param string $method |
47 | * Method |
48 | * |
49 | * @throws \InvalidArgumentException If the supplied method is not supported by imagemagick. |
50 | */ |
51 | public function __construct(Program $program, string $method) |
52 | { |
53 | if (! Support::layerMethod($program, $method)) { |
54 | $message = 'The supplied method (' . $method . ') is not supported by imagemagick'; |
55 | throw new \InvalidArgumentException($message); |
56 | } |
57 | $this->method = $method; |
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->setInputOption(" -layers " . $this->method); |
71 | return $query; |
72 | } |
73 | } |