Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Bordercolor | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
20 | |||
| perform | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 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 | use Karla\Color; |
| 22 | |
| 23 | /** |
| 24 | * Class for handeling bordercolor action |
| 25 | * |
| 26 | * @category Utility |
| 27 | * @author Johannes Skov Frandsen <jsf@greenoak.dk> |
| 28 | * @license http://www.opensource.org/licenses/mit-license.php MIT |
| 29 | * @link https://github.com/localgod/karla Karla |
| 30 | */ |
| 31 | class Bordercolor implements Action |
| 32 | { |
| 33 | /** |
| 34 | * Color |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | private string $color; |
| 39 | |
| 40 | /** |
| 41 | * Construct new bordercolor action |
| 42 | * |
| 43 | * @param string $color |
| 44 | * Color |
| 45 | * |
| 46 | * @throws \InvalidArgumentException If the color supplied could not be parsed. |
| 47 | */ |
| 48 | public function __construct(string $color) |
| 49 | { |
| 50 | if (Color::validHexColor($color) || Color::validRgbColor($color) || Color::validColorName($color)) { |
| 51 | $this->color = $color; |
| 52 | } else { |
| 53 | throw new \InvalidArgumentException('The color supplied could not be parsed'); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * (non-PHPdoc) |
| 59 | * |
| 60 | * @param Query $query |
| 61 | * The query to add the action to |
| 62 | * @return Query |
| 63 | * @see Action::perform() |
| 64 | */ |
| 65 | public function perform(Query $query): Query |
| 66 | { |
| 67 | $query->notWith('bordercolor', \Karla\Query::ARGUMENT_TYPE_INPUT); |
| 68 | if (Color::validColorName($this->color)) { |
| 69 | $query->setInputOption(' -bordercolor ' . $this->color); |
| 70 | } else { |
| 71 | $query->setInputOption(' -bordercolor "' . $this->color . '"'); |
| 72 | } |
| 73 | return $query; |
| 74 | } |
| 75 | } |