| @@ -22,14 +22,14 @@ | ||
| 22 | 22 | * @return string completed img tag. | 
| 23 | 23 | * @see https://book.cakephp.org/3.0/en/views/helpers/html.html#linking-to-images | 
| 24 | 24 | */ | 
| 25 | - public function thumb($path, array $options = [], string $thumb = 'default'): string | |
| 25 | + public function thumb($path, array $options = [ ], string $thumb = 'default'): string | |
| 26 | 26 |      { | 
| 27 | 27 |          if ($thumb !== 'default') { | 
| 28 | 28 |              $path = preg_replace('/default/', $thumb, $path); | 
| 29 | 29 | } | 
| 30 | 30 | |
| 31 | 31 |          if (!is_array($options)) { | 
| 32 | - $options = []; | |
| 32 | + $options = [ ]; | |
| 33 | 33 | } | 
| 34 | 34 | |
| 35 | 35 | return $this->Html->image($path, $options); | 
| @@ -44,9 +44,9 @@ discard block | ||
| 44 | 44 | 'webp', | 
| 45 | 45 | ], | 
| 46 | 46 | 'path' => 'files', | 
| 47 | - 'background' => [255, 255, 255, 127], | |
| 47 | + 'background' => [ 255, 255, 255, 127 ], | |
| 48 | 48 | 'watermark' => '', | 
| 49 | - 'thumbs' => [], | |
| 49 | + 'thumbs' => [ ], | |
| 50 | 50 | ]; | 
| 51 | 51 | |
| 52 | 52 | /** | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | * | 
| 55 | 55 | * @var array | 
| 56 | 56 | */ | 
| 57 | - protected $files = []; | |
| 57 | + protected $files = [ ]; | |
| 58 | 58 | |
| 59 | 59 | /** | 
| 60 | 60 |       * {@inheritdoc} | 
| @@ -71,7 +71,7 @@ discard block | ||
| 71 | 71 | |
| 72 | 72 | $this->setConfig($file, $this->defaultConfig); | 
| 73 | 73 |              } else { | 
| 74 | - $this->setConfig($file, $config[$file] += $this->defaultConfig); | |
| 74 | + $this->setConfig($file, $config[ $file ] += $this->defaultConfig); | |
| 75 | 75 | } | 
| 76 | 76 | } | 
| 77 | 77 | } | 
| @@ -85,9 +85,9 @@ discard block | ||
| 85 | 85 | |
| 86 | 86 |          if (!empty($config)) { | 
| 87 | 87 |              foreach (array_keys($config) as $file) { | 
| 88 | - $this->setFile($file, $data[$file]); | |
| 88 | + $this->setFile($file, $data[ $file ]); | |
| 89 | 89 | |
| 90 | - $data[$file] = $this->createName($data[$file]->getClientFilename()); | |
| 90 | + $data[ $file ] = $this->createName($data[ $file ]->getClientFilename()); | |
| 91 | 91 | } | 
| 92 | 92 | } | 
| 93 | 93 | } | 
| @@ -105,10 +105,10 @@ discard block | ||
| 105 | 105 | $fileConfig = $this->getConfig($file); | 
| 106 | 106 | |
| 107 | 107 | // Move original file | 
| 108 | -                    $fileObject->moveTo($this->getPath($fileConfig['path']) . DS . $entity->{$file}); | |
| 108 | +                    $fileObject->moveTo($this->getPath($fileConfig[ 'path' ]).DS.$entity->{$file}); | |
| 109 | 109 | |
| 110 | 110 | // Prepare thumb files | 
| 111 | -                    if (!empty($fileConfig['thumbs'])) { | |
| 111 | +                    if (!empty($fileConfig[ 'thumbs' ])) { | |
| 112 | 112 |                          $this->createThumbs($entity->{$file}, $fileConfig); | 
| 113 | 113 | } | 
| 114 | 114 | } | 
| @@ -123,11 +123,11 @@ discard block | ||
| 123 | 123 |      { | 
| 124 | 124 | $entity = $this->getTable()->find()->select( | 
| 125 | 125 | array_merge( | 
| 126 | - [$this->getTable()->getPrimaryKey()], | |
| 126 | + [ $this->getTable()->getPrimaryKey() ], | |
| 127 | 127 | array_keys($this->getConfig()) | 
| 128 | 128 | ) | 
| 129 | 129 | )->where([ | 
| 130 | -            $this->getTable()->getAlias() . '.' . $this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, | |
| 130 | +            $this->getTable()->getAlias().'.'.$this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, | |
| 131 | 131 | ])->first(); | 
| 132 | 132 | |
| 133 | 133 | return $this->deleteFiles($entity); | 
| @@ -149,20 +149,20 @@ discard block | ||
| 149 | 149 | */ | 
| 150 | 150 | protected function createThumbs(string $file, array $fileConfig): void | 
| 151 | 151 |      { | 
| 152 | - $filePath = $fileConfig['path'] . DS . $file; | |
| 152 | + $filePath = $fileConfig[ 'path' ].DS.$file; | |
| 153 | 153 | |
| 154 | 154 |          if (is_file($filePath)) { | 
| 155 | 155 | // Check installed image library | 
| 156 | -            if (!extension_loaded($fileConfig['library'])) { | |
| 157 | -                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig['library'])); | |
| 156 | +            if (!extension_loaded($fileConfig[ 'library' ])) { | |
| 157 | +                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig[ 'library' ])); | |
| 158 | 158 | } | 
| 159 | 159 | |
| 160 | 160 | // Get extension from original file | 
| 161 | 161 | $fileExtension = $this->getExtension($file); | 
| 162 | 162 | |
| 163 | - $fileConfig['library'] = mb_strtolower($fileConfig['library']); | |
| 163 | + $fileConfig[ 'library' ] = mb_strtolower($fileConfig[ 'library' ]); | |
| 164 | 164 | |
| 165 | -            switch ($fileConfig['library']) { | |
| 165 | +            switch ($fileConfig[ 'library' ]) { | |
| 166 | 166 | // Get image resource | 
| 167 | 167 | case 'gd': | 
| 168 | 168 |                      switch ($fileExtension) { | 
| @@ -204,7 +204,7 @@ discard block | ||
| 204 | 204 | |
| 205 | 205 | break; | 
| 206 | 206 | default: | 
| 207 | -                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig['library'])); | |
| 207 | +                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig[ 'library' ])); | |
| 208 | 208 | } | 
| 209 | 209 | |
| 210 | 210 | $offsetX = 0; | 
| @@ -213,47 +213,47 @@ discard block | ||
| 213 | 213 | $cropX = 0; | 
| 214 | 214 | $cropY = 0; | 
| 215 | 215 | |
| 216 | -            foreach ($fileConfig['thumbs'] as $thumbName => $thumbConfig) { | |
| 217 | -                if (isset($thumbConfig['width'])) { | |
| 218 | - list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig['width']); | |
| 219 | -                } elseif (isset($thumbConfig['height'])) { | |
| 220 | - list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig['height']); | |
| 221 | -                } elseif (isset($thumbConfig['shorter']) && is_array($thumbConfig['shorter']) && count($thumbConfig['shorter']) === 2) { | |
| 222 | - list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig['shorter'][0], $thumbConfig['shorter'][1]); | |
| 223 | -                } elseif (isset($thumbConfig['longer']) && is_array($thumbConfig['longer']) && count($thumbConfig['longer']) === 2) { | |
| 224 | - list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig['longer'][0], $thumbConfig['longer'][1]); | |
| 225 | -                } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 2) { | |
| 226 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1]); | |
| 227 | -                } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 3) { | |
| 228 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1], $thumbConfig['fit'][2]); | |
| 229 | -                } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 1) { | |
| 230 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0]); | |
| 231 | -                } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 2) { | |
| 232 | - list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0], $thumbConfig['square'][1]); | |
| 216 | +            foreach ($fileConfig[ 'thumbs' ] as $thumbName => $thumbConfig) { | |
| 217 | +                if (isset($thumbConfig[ 'width' ])) { | |
| 218 | + list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig[ 'width' ]); | |
| 219 | +                } elseif (isset($thumbConfig[ 'height' ])) { | |
| 220 | + list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig[ 'height' ]); | |
| 221 | +                } elseif (isset($thumbConfig[ 'shorter' ]) && is_array($thumbConfig[ 'shorter' ]) && count($thumbConfig[ 'shorter' ]) === 2) { | |
| 222 | + list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig[ 'shorter' ][ 0 ], $thumbConfig[ 'shorter' ][ 1 ]); | |
| 223 | +                } elseif (isset($thumbConfig[ 'longer' ]) && is_array($thumbConfig[ 'longer' ]) && count($thumbConfig[ 'longer' ]) === 2) { | |
| 224 | + list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig[ 'longer' ][ 0 ], $thumbConfig[ 'longer' ][ 1 ]); | |
| 225 | +                } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 2) { | |
| 226 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ]); | |
| 227 | +                } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 3) { | |
| 228 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ], $thumbConfig[ 'fit' ][ 2 ]); | |
| 229 | +                } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 1) { | |
| 230 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ]); | |
| 231 | +                } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 2) { | |
| 232 | + list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ], $thumbConfig[ 'square' ][ 1 ]); | |
| 233 | 233 |                  } else { | 
| 234 | 234 |                      throw new ThumbsException(__d('file', 'Unknown type or incorrect parameters of creating thumbnails!')); | 
| 235 | 235 | } | 
| 236 | 236 | |
| 237 | 237 |                  $thumbFile = str_replace('default', $thumbName, $filePath); | 
| 238 | 238 | |
| 239 | -                switch ($fileConfig['library']) { | |
| 239 | +                switch ($fileConfig[ 'library' ]) { | |
| 240 | 240 | // Get image resource | 
| 241 | 241 | case 'gd': | 
| 242 | 242 | $newImage = imagecreatetruecolor($newWidth, $newHeight); | 
| 243 | 243 | |
| 244 | -                        if (is_array($fileConfig['background'])) { | |
| 244 | +                        if (is_array($fileConfig[ 'background' ])) { | |
| 245 | 245 | // Set background color and transparent indicates | 
| 246 | - imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); | |
| 246 | + imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); | |
| 247 | 247 | } | 
| 248 | 248 | |
| 249 | 249 | imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); | 
| 250 | 250 | |
| 251 | -                        if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { | |
| 251 | +                        if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { | |
| 252 | 252 | $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY)); | 
| 253 | 253 | |
| 254 | -                            if (is_array($fileConfig['background'])) { | |
| 254 | +                            if (is_array($fileConfig[ 'background' ])) { | |
| 255 | 255 | // Set background color and transparent indicates | 
| 256 | - imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); | |
| 256 | + imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); | |
| 257 | 257 | } | 
| 258 | 258 | |
| 259 | 259 | imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight); | 
| @@ -265,10 +265,10 @@ discard block | ||
| 265 | 265 | imagesavealpha($newImage, true); | 
| 266 | 266 | |
| 267 | 267 | // Watermark | 
| 268 | -                        if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { | |
| 268 | +                        if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { | |
| 269 | 269 | $watermarkImage = imagecreatefromstring($watermarkSource); | 
| 270 | 270 | |
| 271 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig['watermark']); | |
| 271 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); | |
| 272 | 272 | |
| 273 | 273 | // Set transparent | 
| 274 | 274 | imagealphablending($newImage, true); | 
| @@ -307,16 +307,16 @@ discard block | ||
| 307 | 307 |                          $newImage->setimagebackgroundcolor('transparent'); | 
| 308 | 308 | $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY); | 
| 309 | 309 | |
| 310 | -                        if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { | |
| 310 | +                        if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { | |
| 311 | 311 | $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY); | 
| 312 | 312 | } | 
| 313 | 313 | |
| 314 | 314 | // Watermark | 
| 315 | -                        if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { | |
| 315 | +                        if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { | |
| 316 | 316 | $watermarkImage = new \Imagick(); | 
| 317 | 317 | $watermarkImage->readimageblob($watermarkSource); | 
| 318 | 318 | |
| 319 | - list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig['watermark']); | |
| 319 | + list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); | |
| 320 | 320 | |
| 321 | 321 | $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY); | 
| 322 | 322 | } | 
| @@ -345,10 +345,10 @@ discard block | ||
| 345 | 345 | |
| 346 | 346 |          if (!empty($config)) { | 
| 347 | 347 |              foreach ($config as $file => $fileConfig) { | 
| 348 | -                if (isset($entity[$file])) { | |
| 349 | - $path = $fileConfig['path'] . DS . substr($entity[$file], 0, 37); | |
| 348 | +                if (isset($entity[ $file ])) { | |
| 349 | + $path = $fileConfig[ 'path' ].DS.substr($entity[ $file ], 0, 37); | |
| 350 | 350 | |
| 351 | -                    foreach (glob($path . '*') as $file) { | |
| 351 | +                    foreach (glob($path.'*') as $file) { | |
| 352 | 352 |                          if (file_exists($file)) { | 
| 353 | 353 | unlink($file); | 
| 354 | 354 | } | 
| @@ -378,7 +378,7 @@ discard block | ||
| 378 | 378 | */ | 
| 379 | 379 | protected function setFile(string $file, UploadedFile $data): void | 
| 380 | 380 |      { | 
| 381 | - $this->files[$file] = $data; | |
| 381 | + $this->files[ $file ] = $data; | |
| 382 | 382 | } | 
| 383 | 383 | |
| 384 | 384 | /** | 
| @@ -419,7 +419,7 @@ discard block | ||
| 419 | 419 | */ | 
| 420 | 420 | protected function createName(string $name): string | 
| 421 | 421 |      { | 
| 422 | - return Text::uuid() . '_default.' . $this->getExtension($name); | |
| 422 | + return Text::uuid().'_default.'.$this->getExtension($name); | |
| 423 | 423 | } | 
| 424 | 424 | |
| 425 | 425 | /** | 
| @@ -464,43 +464,43 @@ discard block | ||
| 464 | 464 |      { | 
| 465 | 465 |          switch ($positionValue) { | 
| 466 | 466 | case 1: // Top left | 
| 467 | - return [$offsetX, $offsetY]; | |
| 467 | + return [ $offsetX, $offsetY ]; | |
| 468 | 468 | |
| 469 | 469 | break; | 
| 470 | 470 | case 2: // Top center | 
| 471 | - return [($newWidth / 2) - ($watermarkWidth / 2), $offsetY]; | |
| 471 | + return [ ($newWidth / 2) - ($watermarkWidth / 2), $offsetY ]; | |
| 472 | 472 | |
| 473 | 473 | break; | 
| 474 | 474 | case 3: // Top right | 
| 475 | - return [($newWidth - $watermarkWidth - $offsetX), $offsetY]; | |
| 475 | + return [ ($newWidth - $watermarkWidth - $offsetX), $offsetY ]; | |
| 476 | 476 | |
| 477 | 477 | break; | 
| 478 | 478 | case 4: // Middle left | 
| 479 | - return [$offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; | |
| 479 | + return [ $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | |
| 480 | 480 | |
| 481 | 481 | break; | 
| 482 | 482 | case 5: // Middle center | 
| 483 | - return [intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2))]; | |
| 483 | + return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | |
| 484 | 484 | |
| 485 | 485 | break; | 
| 486 | 486 | case 6: // Middle right | 
| 487 | - return [($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; | |
| 487 | + return [ ($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | |
| 488 | 488 | |
| 489 | 489 | break; | 
| 490 | 490 | case 7: // Bottom left | 
| 491 | - return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | |
| 491 | + return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 492 | 492 | |
| 493 | 493 | break; | 
| 494 | 494 | case 8: // Bottom center | 
| 495 | - return [intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY]; | |
| 495 | + return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 496 | 496 | |
| 497 | 497 | break; | 
| 498 | 498 | case 9: // Bottom right | 
| 499 | - return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | |
| 499 | + return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | |
| 500 | 500 | |
| 501 | 501 | break; | 
| 502 | 502 | default: | 
| 503 | - return [$offsetX, $offsetY]; | |
| 503 | + return [ $offsetX, $offsetY ]; | |
| 504 | 504 | |
| 505 | 505 | break; | 
| 506 | 506 | } | 
| @@ -523,7 +523,7 @@ discard block | ||
| 523 | 523 | $newHeight = intval($newWidth * ($originalHeight / $originalWidth)); | 
| 524 | 524 | } | 
| 525 | 525 | |
| 526 | - return [$newWidth, $newHeight]; | |
| 526 | + return [ $newWidth, $newHeight ]; | |
| 527 | 527 | } | 
| 528 | 528 | |
| 529 | 529 | /** | 
| @@ -543,7 +543,7 @@ discard block | ||
| 543 | 543 | $newWidth = intval($newHeight * ($originalWidth / $originalHeight)); | 
| 544 | 544 | } | 
| 545 | 545 | |
| 546 | - return [$newWidth, $newHeight]; | |
| 546 | + return [ $newWidth, $newHeight ]; | |
| 547 | 547 | } | 
| 548 | 548 | |
| 549 | 549 | /** | 
| @@ -563,7 +563,7 @@ discard block | ||
| 563 | 563 | list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); | 
| 564 | 564 | } | 
| 565 | 565 | |
| 566 | - return [$newWidth, $newHeight]; | |
| 566 | + return [ $newWidth, $newHeight ]; | |
| 567 | 567 | } | 
| 568 | 568 | |
| 569 | 569 | /** | 
| @@ -583,7 +583,7 @@ discard block | ||
| 583 | 583 | list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); | 
| 584 | 584 | } | 
| 585 | 585 | |
| 586 | - return [$newWidth, $newHeight]; | |
| 586 | + return [ $newWidth, $newHeight ]; | |
| 587 | 587 | } | 
| 588 | 588 | |
| 589 | 589 | /** | 
| @@ -609,7 +609,7 @@ discard block | ||
| 609 | 609 |              } else { | 
| 610 | 610 | $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 611 | 611 | |
| 612 | -                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) { | |
| 612 | +                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) { | |
| 613 | 613 | $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 614 | 614 | } | 
| 615 | 615 | } | 
| @@ -619,25 +619,25 @@ discard block | ||
| 619 | 619 |              } else { | 
| 620 | 620 | $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 621 | 621 | |
| 622 | -                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) { | |
| 622 | +                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) { | |
| 623 | 623 | $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
| 624 | 624 | } | 
| 625 | 625 | } | 
| 626 | 626 | } | 
| 627 | 627 | |
| 628 | -        if ($newWidth < $newSizes[0]) { | |
| 629 | - $cropX = ($newSizes[0] - $newWidth) / 2; | |
| 628 | +        if ($newWidth < $newSizes[ 0 ]) { | |
| 629 | + $cropX = ($newSizes[ 0 ] - $newWidth) / 2; | |
| 630 | 630 |          } else { | 
| 631 | - $offsetX = ($newWidth - $newSizes[0]) / 2; | |
| 631 | + $offsetX = ($newWidth - $newSizes[ 0 ]) / 2; | |
| 632 | 632 | } | 
| 633 | 633 | |
| 634 | -        if ($newHeight < $newSizes[1]) { | |
| 635 | - $cropY = ($newSizes[1] - $newHeight) / 2; | |
| 634 | +        if ($newHeight < $newSizes[ 1 ]) { | |
| 635 | + $cropY = ($newSizes[ 1 ] - $newHeight) / 2; | |
| 636 | 636 |          } else { | 
| 637 | - $offsetY = ($newHeight - $newSizes[1]) / 2; | |
| 637 | + $offsetY = ($newHeight - $newSizes[ 1 ]) / 2; | |
| 638 | 638 | } | 
| 639 | 639 | |
| 640 | - return [$newSizes[0], $newSizes[1], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; | |
| 640 | + return [ $newSizes[ 0 ], $newSizes[ 1 ], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; | |
| 641 | 641 | } | 
| 642 | 642 | |
| 643 | 643 | /** | 
| @@ -682,6 +682,6 @@ discard block | ||
| 682 | 682 | } | 
| 683 | 683 | } | 
| 684 | 684 | |
| 685 | - return [$newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; | |
| 685 | + return [ $newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; | |
| 686 | 686 | } | 
| 687 | 687 | } | 
| 688 | 688 | \ No newline at end of file |