1 | <?php |
||
7 | abstract class AbstractImage |
||
8 | { |
||
9 | |||
10 | protected $positions = [ |
||
11 | 'NORTHWEST' => ['x' => 0, 'y' => 0, 'padX' => 10, 'padY' => 10], |
||
12 | 'NORTH' => ['x' => 1, 'y' => 0, 'padX' => 0, 'padY' => 10], |
||
13 | 'NORTHEAST' => ['x' => 2, 'y' => 0, 'padX' => -10, 'padY' => 10], |
||
14 | 'WEST' => ['x' => 0, 'y' => 1, 'padX' => 10, 'padY' => 0], |
||
15 | 'CENTER' => ['x' => 1, 'y' => 1, 'padX' => 0, 'padY' => 0], |
||
16 | 'EAST' => ['x' => 2, 'y' => 1, 'padX' => -10, 'padY' => 0], |
||
17 | 'SOUTHWEST' => ['x' => 0, 'y' => 2, 'padX' => 10, 'padY' => -10], |
||
18 | 'SOUTH' => ['x' => 1, 'y' => 2, 'padX' => 0, 'padY' => -10], |
||
19 | 'SOUTHEAST' => ['x' => 2, 'y' => 2, 'padX' => -10, 'padY' => -10] |
||
20 | ]; |
||
21 | |||
22 | protected $image; |
||
23 | |||
24 | protected $width; |
||
25 | |||
26 | protected $height; |
||
27 | |||
28 | abstract protected function setSizes(): void; |
||
29 | |||
30 | abstract protected function resize(int $width, int $height): ImageInterface; |
||
31 | |||
32 | abstract protected function prepareWatermark(Image $watermark, int $x, int $y): ImageInterface; |
||
33 | |||
34 | abstract protected function tmp(string $source): ImageInterface; |
||
35 | |||
36 | abstract public function __toString(): string; |
||
37 | |||
38 | /** |
||
39 | * @param string $image |
||
40 | * @throws \Exception |
||
41 | */ |
||
42 | protected function init(string $image) |
||
58 | |||
59 | /** |
||
60 | * @param string $url |
||
61 | * @return \Exception|null |
||
62 | * @throws \Exception |
||
63 | */ |
||
64 | protected function getImageByURL(string $url): ?\Exception |
||
80 | |||
81 | /** |
||
82 | * @param string $base64 |
||
83 | * @throws \Exception |
||
84 | */ |
||
85 | protected function getImageByBase64(string $base64): void |
||
89 | |||
90 | protected function setImage($image): void |
||
94 | |||
95 | public function getImage() |
||
99 | |||
100 | public function getWidth(): int |
||
104 | |||
105 | protected function setWidth(int $width): void |
||
109 | |||
110 | public function getHeight(): int |
||
114 | |||
115 | protected function setHeight(int $height): void |
||
119 | |||
120 | /** |
||
121 | * @param int $height |
||
122 | * @return ImageInterface |
||
123 | */ |
||
124 | public function resizeByHeight(int $height): ImageInterface |
||
128 | |||
129 | /** |
||
130 | * @param int $width |
||
131 | * @return ImageInterface |
||
132 | */ |
||
133 | public function resizeByWidth(int $width): ImageInterface |
||
137 | |||
138 | /** |
||
139 | * @param int $percent |
||
140 | * @return ImageInterface |
||
141 | */ |
||
142 | public function resizeByPercent(int $percent): ImageInterface |
||
148 | |||
149 | /** |
||
150 | * @param string $mode |
||
151 | * @param int $param |
||
152 | * @return ImageInterface |
||
153 | * @throws \Exception |
||
154 | */ |
||
155 | public function resizeBy(string $mode, int $param): ImageInterface |
||
168 | |||
169 | /** |
||
170 | * @param Image $watermark |
||
171 | * @param string $position |
||
172 | * @return ImageInterface |
||
173 | * @throws \Exception |
||
174 | */ |
||
175 | public function watermark(Image $watermark, string $position): ImageInterface |
||
187 | |||
188 | public function getBase64(): string |
||
193 | } |
||
194 |
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements.
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.