@@ -119,10 +119,10 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | protected function calculateParams() |
| 121 | 121 | { |
| 122 | - $this->positionStartY = (int)($this->imageHeight / 100 * $this->marginTopInPercents); |
|
| 123 | - $this->rowHeightInPx = (int)($this->imageHeight / 100 * $this->rowHeight); |
|
| 124 | - $this->fontSizeInPx = (int)($this->imageHeight / 100 * $this->fontSizeInPercents); |
|
| 125 | - $this->positionX = (int)($this->imageWidth / 100 * $this->paddingLeftRightInPercents); |
|
| 122 | + $this->positionStartY = (int) ($this->imageHeight / 100 * $this->marginTopInPercents); |
|
| 123 | + $this->rowHeightInPx = (int) ($this->imageHeight / 100 * $this->rowHeight); |
|
| 124 | + $this->fontSizeInPx = (int) ($this->imageHeight / 100 * $this->fontSizeInPercents); |
|
| 125 | + $this->positionX = (int) ($this->imageWidth / 100 * $this->paddingLeftRightInPercents); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | foreach ($this->rows as $rowNumber => $row) { |
| 161 | 161 | $string = implode(' ', $row); |
| 162 | - $positionY = (int)$this->positionStartY + ($rowNumber * $this->rowHeightInPx); |
|
| 162 | + $positionY = (int) $this->positionStartY + ($rowNumber * $this->rowHeightInPx); |
|
| 163 | 163 | imagettftext($this->image, $this->fontSizeInPx, 0, $this->positionX, $positionY, $this->textColor, $this->font, $string); |
| 164 | 164 | } |
| 165 | 165 | } |
@@ -89,8 +89,9 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | protected function loadImage(string $backgroundImagePath) |
| 91 | 91 | { |
| 92 | - if (!file_exists($backgroundImagePath)) |
|
| 93 | - throw new ImageNotFoundException(); |
|
| 92 | + if (!file_exists($backgroundImagePath)) { |
|
| 93 | + throw new ImageNotFoundException(); |
|
| 94 | + } |
|
| 94 | 95 | $this->image = imagecreatefrompng($backgroundImagePath); |
| 95 | 96 | list($this->imageWidth, $this->imageHeight) = getimagesize($backgroundImagePath); |
| 96 | 97 | } |
@@ -130,8 +131,9 @@ discard block |
||
| 130 | 131 | */ |
| 131 | 132 | protected function prepareRows(): void |
| 132 | 133 | { |
| 133 | - if (!file_exists($this->font)) |
|
| 134 | - throw new FontNotFoundException(); |
|
| 134 | + if (!file_exists($this->font)) { |
|
| 135 | + throw new FontNotFoundException(); |
|
| 136 | + } |
|
| 135 | 137 | |
| 136 | 138 | $wordsArray = explode(' ', $this->text); |
| 137 | 139 | $validRowWidth = $this->imageWidth - $this->positionX * 2; |
@@ -196,8 +198,9 @@ discard block |
||
| 196 | 198 | { |
| 197 | 199 | $colorInHex = str_replace('#', '', $colorInHex); |
| 198 | 200 | |
| 199 | - if (!ctype_xdigit($colorInHex) || strlen($colorInHex) !== 6) |
|
| 200 | - throw new InvalidHexColorException(); |
|
| 201 | + if (!ctype_xdigit($colorInHex) || strlen($colorInHex) !== 6) { |
|
| 202 | + throw new InvalidHexColorException(); |
|
| 203 | + } |
|
| 201 | 204 | |
| 202 | 205 | $red = hexdec(substr($colorInHex, 0, 2)); |
| 203 | 206 | $green = hexdec(substr($colorInHex, 2, 2)); |
@@ -214,8 +217,9 @@ discard block |
||
| 214 | 217 | public |
| 215 | 218 | function setFontSize(int $size) |
| 216 | 219 | { |
| 217 | - if ($size < 1 || $size > 20) |
|
| 218 | - throw new InvalidFontSizeException(); |
|
| 220 | + if ($size < 1 || $size > 20) { |
|
| 221 | + throw new InvalidFontSizeException(); |
|
| 222 | + } |
|
| 219 | 223 | $this->fontSizeInPercents = $size; |
| 220 | 224 | return $this; |
| 221 | 225 | } |
@@ -228,8 +232,9 @@ discard block |
||
| 228 | 232 | public |
| 229 | 233 | function setPadding(int $percent) |
| 230 | 234 | { |
| 231 | - if ($percent < 1 || $percent > 100) |
|
| 232 | - throw new InvalidPositionValueException(); |
|
| 235 | + if ($percent < 1 || $percent > 100) { |
|
| 236 | + throw new InvalidPositionValueException(); |
|
| 237 | + } |
|
| 233 | 238 | $this->paddingLeftRightInPercents = $percent; |
| 234 | 239 | return $this; |
| 235 | 240 | } |
@@ -241,8 +246,9 @@ discard block |
||
| 241 | 246 | */ |
| 242 | 247 | public function setMarginTopInPercents(int $percent) |
| 243 | 248 | { |
| 244 | - if ($percent < 1 || $percent > 100) |
|
| 245 | - throw new InvalidPositionValueException(); |
|
| 249 | + if ($percent < 1 || $percent > 100) { |
|
| 250 | + throw new InvalidPositionValueException(); |
|
| 251 | + } |
|
| 246 | 252 | $this->marginTopInPercents = $percent; |
| 247 | 253 | return $this; |
| 248 | 254 | } |
@@ -255,8 +261,9 @@ discard block |
||
| 255 | 261 | public |
| 256 | 262 | function setRowHeight(int $percent) |
| 257 | 263 | { |
| 258 | - if ($percent < 1 || $percent > 30) |
|
| 259 | - throw new InvalidRowHeightException(); |
|
| 264 | + if ($percent < 1 || $percent > 30) { |
|
| 265 | + throw new InvalidRowHeightException(); |
|
| 266 | + } |
|
| 260 | 267 | $this->rowHeight = $percent; |
| 261 | 268 | return $this; |
| 262 | 269 | } |