Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Size | |
100.00% |
5 / 5 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 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\Query; |
| 20 | use Karla\Action; |
| 21 | |
| 22 | /** |
| 23 | * Class for handling size 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 | */ |
| 30 | class Size implements Action |
| 31 | { |
| 32 | /** |
| 33 | * Width |
| 34 | * |
| 35 | * @var int|null |
| 36 | */ |
| 37 | private int|null $width; |
| 38 | |
| 39 | /** |
| 40 | * Height |
| 41 | * |
| 42 | * @var int|null |
| 43 | */ |
| 44 | private int|null $height; |
| 45 | |
| 46 | /** |
| 47 | * Construct a new size action |
| 48 | * |
| 49 | * @param int|null $width New width |
| 50 | * @param int|null $height New height |
| 51 | */ |
| 52 | public function __construct(int|null $width, int|null $height) |
| 53 | { |
| 54 | $this->width = $width; |
| 55 | $this->height = $height; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * (non-PHPdoc) |
| 60 | * |
| 61 | * @param Query $query The query to add the action to |
| 62 | * |
| 63 | * @see Action::perform() |
| 64 | */ |
| 65 | public function perform(Query $query): Query |
| 66 | { |
| 67 | $query->notWith('size', Query::ARGUMENT_TYPE_INPUT); |
| 68 | |
| 69 | $query->setInputOption(" -size " . $this->width . "x" . $this->height . " "); |
| 70 | |
| 71 | return $query; |
| 72 | } |
| 73 | } |