| 1 | <?php |
||
| 10 | class ImageEditor implements ImageEditingInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var \Intervention\Image\Image |
||
| 14 | */ |
||
| 15 | private $image; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var int |
||
| 19 | */ |
||
| 20 | private $quality = 100; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * ImageEditor constructor. |
||
| 24 | * |
||
| 25 | * @param $file |
||
| 26 | */ |
||
| 27 | public function __construct($file) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Crop Image |
||
| 34 | * |
||
| 35 | * @param $width |
||
| 36 | * @param $height |
||
| 37 | * @param null $x_pos |
||
| 38 | * @param null $y_pos |
||
| 39 | * @return ImageEditingInterface |
||
| 40 | */ |
||
| 41 | public function crop($width, $height, $x_pos = null, $y_pos = null): ImageEditingInterface |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param $width |
||
| 50 | * @param $height |
||
| 51 | * @return ImageEditingInterface |
||
| 52 | */ |
||
| 53 | public function resize($width, $height): ImageEditingInterface |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Set Quality |
||
| 66 | * |
||
| 67 | * @param $quality |
||
| 68 | * @return ImageEditingInterface |
||
| 69 | */ |
||
| 70 | public function setQuality($quality): ImageEditingInterface |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Get Stream |
||
| 79 | * |
||
| 80 | * Finalize edits and get the finished product. |
||
| 81 | * |
||
| 82 | * @return string |
||
| 83 | */ |
||
| 84 | public function getStream(): string |
||
| 88 | } |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: