quickwebp
/
includes
/
vendor
/
intervention
/
image
/
src
/
Intervention
/
Image
/
Commands
/
AbstractCommand.php
AbstractCommand.php in QuickWebP – WebP & AVIF Image Optimizer, Compression & SEO for WordPress 3.2.1, at includes/vendor/intervention/image/src/Intervention/Image/Commands/AbstractCommand.php
| 1 | <?php |
| 2 | |
| 3 | namespace Intervention\Image\Commands; |
| 4 | |
| 5 | use Intervention\Image\Commands\Argument; |
| 6 | |
| 7 | abstract class AbstractCommand |
| 8 | { |
| 9 | /** |
| 10 | * Arguments of command |
| 11 | * |
| 12 | * @var array |
| 13 | */ |
| 14 | public $arguments; |
| 15 | |
| 16 | /** |
| 17 | * Output of command |
| 18 | * |
| 19 | * @var mixed |
| 20 | */ |
| 21 | protected $output; |
| 22 | |
| 23 | /** |
| 24 | * Executes current command on given image |
| 25 | * |
| 26 | * @param \Intervention\Image\Image $image |
| 27 | * @return mixed |
| 28 | */ |
| 29 | abstract public function execute($image); |
| 30 | |
| 31 | /** |
| 32 | * Creates new command instance |
| 33 | * |
| 34 | * @param array $arguments |
| 35 | */ |
| 36 | public function __construct($arguments) |
| 37 | { |
| 38 | $this->arguments = $arguments; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Creates new argument instance from given argument key |
| 43 | * |
| 44 | * @param int $key |
| 45 | * @return \Intervention\Image\Commands\Argument |
| 46 | */ |
| 47 | public function argument($key) |
| 48 | { |
| 49 | return new Argument($this, $key); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Returns output data of current command |
| 54 | * |
| 55 | * @return mixed |
| 56 | */ |
| 57 | public function getOutput() |
| 58 | { |
| 59 | return $this->output ? $this->output : null; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Determines if current instance has output data |
| 64 | * |
| 65 | * @return boolean |
| 66 | */ |
| 67 | public function hasOutput() |
| 68 | { |
| 69 | return ! is_null($this->output); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Sets output data of current command |
| 74 | * |
| 75 | * @param mixed $value |
| 76 | */ |
| 77 | public function setOutput($value) |
| 78 | { |
| 79 | $this->output = $value; |
| 80 | } |
| 81 | } |
| 82 |