Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Resample | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| perform | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |||
| 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 handeling resample 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 Resample implements Action |
| 31 | { |
| 32 | /** |
| 33 | * New width |
| 34 | * |
| 35 | * @var integer |
| 36 | */ |
| 37 | private int $newWidth; |
| 38 | |
| 39 | /** |
| 40 | * New height |
| 41 | * |
| 42 | * @var integer |
| 43 | */ |
| 44 | private int $newHeight; |
| 45 | |
| 46 | /** |
| 47 | * Construct a new size action |
| 48 | * |
| 49 | * @param integer $newWidth |
| 50 | * New width |
| 51 | * @param integer $newHeight |
| 52 | * New height |
| 53 | * |
| 54 | * @throws \InvalidArgumentException |
| 55 | */ |
| 56 | public function __construct(int $newWidth, int|null $newHeight) |
| 57 | { |
| 58 | $this->newWidth = $newWidth; |
| 59 | $newHeight == null ? $this->newHeight = 0 : $this->newHeight = $newHeight; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * (non-PHPdoc) |
| 64 | * |
| 65 | * @param Query $query |
| 66 | * The query to add the action to |
| 67 | * @return Query |
| 68 | * @see Action::perform() |
| 69 | */ |
| 70 | public function perform(Query $query): Query |
| 71 | { |
| 72 | $query->notWith('resample', Query::ARGUMENT_TYPE_INPUT); |
| 73 | $query->notWith('resize', Query::ARGUMENT_TYPE_INPUT); |
| 74 | |
| 75 | $option = " -resample '"; |
| 76 | if ($this->newWidth != "" && $this->newHeight != "") { |
| 77 | $option = $option . $this->newWidth . "x" . $this->newHeight; |
| 78 | } elseif ($this->newWidth != "") { |
| 79 | $option = $option . $this->newWidth; |
| 80 | } |
| 81 | $option = $option . "' "; |
| 82 | $query->setInputOption($option); |
| 83 | |
| 84 | return $query; |
| 85 | } |
| 86 | } |