|  | @@ -45,9 +45,9 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 45 | 45 |              'webp', | 
                                                                                                            
                                                            | 46 | 46 |          ], | 
                                                                                                            
                                                            | 47 | 47 |          'path' => 'files', | 
                                                                                                            
                                                            | 48 |  | -        'background' => [255, 255, 255, 127], | 
                                                                                                            
                                                            |  | 48 | +        'background' => [ 255, 255, 255, 127 ], | 
                                                                                                            
                                                            | 49 | 49 |          'watermark' => '', | 
                                                                                                            
                                                            | 50 |  | -        'thumbs' => [], | 
                                                                                                            
                                                            |  | 50 | +        'thumbs' => [ ], | 
                                                                                                            
                                                            | 51 | 51 |      ]; | 
                                                                                                            
                                                            | 52 | 52 |   | 
                                                                                                            
                                                            | 53 | 53 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -55,7 +55,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 55 | 55 |       * | 
                                                                                                            
                                                            | 56 | 56 |       * @var array | 
                                                                                                            
                                                            | 57 | 57 |       */ | 
                                                                                                            
                                                            | 58 |  | -    protected $files = []; | 
                                                                                                            
                                                            |  | 58 | +    protected $files = [ ]; | 
                                                                                                            
                                                            | 59 | 59 |   | 
                                                                                                            
                                                            | 60 | 60 |      /** | 
                                                                                                            
                                                            | 61 | 61 |       * {@inheritdoc} | 
                                                                                                                                                        
                                                        |  | @@ -72,7 +72,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 72 | 72 |   | 
                                                                                                            
                                                            | 73 | 73 |                  $this->setConfig($file, $this->defaultConfig); | 
                                                                                                            
                                                            | 74 | 74 |              } else { | 
                                                                                                            
                                                            | 75 |  | -                $this->setConfig($file, $config[$file] += $this->defaultConfig); | 
                                                                                                            
                                                            |  | 75 | +                $this->setConfig($file, $config[ $file ] += $this->defaultConfig); | 
                                                                                                            
                                                            | 76 | 76 |              } | 
                                                                                                            
                                                            | 77 | 77 |          } | 
                                                                                                            
                                                            | 78 | 78 |      } | 
                                                                                                                                                        
                                                        |  | @@ -86,10 +86,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 86 | 86 |   | 
                                                                                                            
                                                            | 87 | 87 |          if (!empty($config)) { | 
                                                                                                            
                                                            | 88 | 88 |              foreach (array_keys($config) as $file) { | 
                                                                                                            
                                                            | 89 |  | -                if (!empty($data[$file])) { | 
                                                                                                            
                                                            | 90 |  | -                    $this->setFile($file, $data[$file]); | 
                                                                                                            
                                                            |  | 89 | +                if (!empty($data[ $file ])) { | 
                                                                                                            
                                                            |  | 90 | +                    $this->setFile($file, $data[ $file ]); | 
                                                                                                            
                                                            | 91 | 91 |   | 
                                                                                                            
                                                            | 92 |  | -                    $data[$file] = $this->createName($data[$file]->getClientFilename()); | 
                                                                                                            
                                                            |  | 92 | +                    $data[ $file ] = $this->createName($data[ $file ]->getClientFilename()); | 
                                                                                                            
                                                            | 93 | 93 |                  } | 
                                                                                                            
                                                            | 94 | 94 |              } | 
                                                                                                            
                                                            | 95 | 95 |          } | 
                                                                                                                                                        
                                                        |  | @@ -109,10 +109,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 109 | 109 |                          $fileConfig = $this->getConfig($file); | 
                                                                                                            
                                                            | 110 | 110 |   | 
                                                                                                            
                                                            | 111 | 111 |                          // Move original file | 
                                                                                                            
                                                            | 112 |  | -                        $fileObject->moveTo($this->getPath($fileConfig['path']) . DS . $entity->{$file}); | 
                                                                                                            
                                                            |  | 112 | +                        $fileObject->moveTo($this->getPath($fileConfig[ 'path' ]).DS.$entity->{$file}); | 
                                                                                                            
                                                            | 113 | 113 |   | 
                                                                                                            
                                                            | 114 | 114 |                          // Prepare thumb files | 
                                                                                                            
                                                            | 115 |  | -                        if (!empty($fileConfig['thumbs'])) { | 
                                                                                                            
                                                            |  | 115 | +                        if (!empty($fileConfig[ 'thumbs' ])) { | 
                                                                                                            
                                                            | 116 | 116 |                              $this->createThumbs($entity->{$file}, $fileConfig); | 
                                                                                                            
                                                            | 117 | 117 |                          } | 
                                                                                                            
                                                            | 118 | 118 |                      } | 
                                                                                                                                                        
                                                        |  | @@ -130,11 +130,11 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 130 | 130 |      { | 
                                                                                                            
                                                            | 131 | 131 |          $entity = $this->getTable()->find()->select( | 
                                                                                                            
                                                            | 132 | 132 |              array_merge( | 
                                                                                                            
                                                            | 133 |  | -                [$this->getTable()->getPrimaryKey()], | 
                                                                                                            
                                                            |  | 133 | +                [ $this->getTable()->getPrimaryKey() ], | 
                                                                                                            
                                                            | 134 | 134 |                  array_keys($this->getConfig()) | 
                                                                                                            
                                                            | 135 | 135 |              ) | 
                                                                                                            
                                                            | 136 | 136 |          )->where([ | 
                                                                                                            
                                                            | 137 |  | -            $this->getTable()->getAlias() . '.' . $this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, | 
                                                                                                            
                                                            |  | 137 | +            $this->getTable()->getAlias().'.'.$this->getTable()->getPrimaryKey() => $entity->{$this->getTable()->getPrimaryKey()}, | 
                                                                                                            
                                                            | 138 | 138 |          ])->first(); | 
                                                                                                            
                                                            | 139 | 139 |   | 
                                                                                                            
                                                            | 140 | 140 |          return $this->deleteFiles($entity); | 
                                                                                                                                                        
                                                        |  | @@ -156,20 +156,20 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 156 | 156 |       */ | 
                                                                                                            
                                                            | 157 | 157 |      protected function createThumbs(string $file, array $fileConfig): void | 
                                                                                                            
                                                            | 158 | 158 |      { | 
                                                                                                            
                                                            | 159 |  | -        $filePath = $fileConfig['path'] . DS . $file; | 
                                                                                                            
                                                            |  | 159 | +        $filePath = $fileConfig[ 'path' ].DS.$file; | 
                                                                                                            
                                                            | 160 | 160 |   | 
                                                                                                            
                                                            | 161 | 161 |          if (is_file($filePath)) { | 
                                                                                                            
                                                            | 162 | 162 |              // Check installed image library | 
                                                                                                            
                                                            | 163 |  | -            if (!extension_loaded($fileConfig['library'])) { | 
                                                                                                            
                                                            | 164 |  | -                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig['library'])); | 
                                                                                                            
                                                            |  | 163 | +            if (!extension_loaded($fileConfig[ 'library' ])) { | 
                                                                                                            
                                                            |  | 164 | +                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $fileConfig[ 'library' ])); | 
                                                                                                            
                                                            | 165 | 165 |              } | 
                                                                                                            
                                                            | 166 | 166 |   | 
                                                                                                            
                                                            | 167 | 167 |              // Get extension from original file | 
                                                                                                            
                                                            | 168 | 168 |              $fileExtension = $this->getExtension($file); | 
                                                                                                            
                                                            | 169 | 169 |   | 
                                                                                                            
                                                            | 170 |  | -            $fileConfig['library'] = mb_strtolower($fileConfig['library']); | 
                                                                                                            
                                                            |  | 170 | +            $fileConfig[ 'library' ] = mb_strtolower($fileConfig[ 'library' ]); | 
                                                                                                            
                                                            | 171 | 171 |   | 
                                                                                                            
                                                            | 172 |  | -            switch ($fileConfig['library']) { | 
                                                                                                            
                                                            |  | 172 | +            switch ($fileConfig[ 'library' ]) { | 
                                                                                                            
                                                            | 173 | 173 |                  // Get image resource | 
                                                                                                            
                                                            | 174 | 174 |                  case 'gd': | 
                                                                                                            
                                                            | 175 | 175 |                      switch ($fileExtension) { | 
                                                                                                                                                        
                                                        |  | @@ -211,7 +211,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 211 | 211 |   | 
                                                                                                            
                                                            | 212 | 212 |                      break; | 
                                                                                                            
                                                            | 213 | 213 |                  default: | 
                                                                                                            
                                                            | 214 |  | -                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig['library'])); | 
                                                                                                            
                                                            |  | 214 | +                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $fileConfig[ 'library' ])); | 
                                                                                                            
                                                            | 215 | 215 |              } | 
                                                                                                            
                                                            | 216 | 216 |   | 
                                                                                                            
                                                            | 217 | 217 |              $offsetX = 0; | 
                                                                                                                                                        
                                                        |  | @@ -220,47 +220,47 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 220 | 220 |              $cropX = 0; | 
                                                                                                            
                                                            | 221 | 221 |              $cropY = 0; | 
                                                                                                            
                                                            | 222 | 222 |   | 
                                                                                                            
                                                            | 223 |  | -            foreach ($fileConfig['thumbs'] as $thumbName => $thumbConfig) { | 
                                                                                                            
                                                            | 224 |  | -                if (isset($thumbConfig['width'])) { | 
                                                                                                            
                                                            | 225 |  | -                    list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig['width']); | 
                                                                                                            
                                                            | 226 |  | -                } elseif (isset($thumbConfig['height'])) { | 
                                                                                                            
                                                            | 227 |  | -                    list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig['height']); | 
                                                                                                            
                                                            | 228 |  | -                } elseif (isset($thumbConfig['shorter']) && is_array($thumbConfig['shorter']) && count($thumbConfig['shorter']) === 2) { | 
                                                                                                            
                                                            | 229 |  | -                    list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig['shorter'][0], $thumbConfig['shorter'][1]); | 
                                                                                                            
                                                            | 230 |  | -                } elseif (isset($thumbConfig['longer']) && is_array($thumbConfig['longer']) && count($thumbConfig['longer']) === 2) { | 
                                                                                                            
                                                            | 231 |  | -                    list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig['longer'][0], $thumbConfig['longer'][1]); | 
                                                                                                            
                                                            | 232 |  | -                } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 2) { | 
                                                                                                            
                                                            | 233 |  | -                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1]); | 
                                                                                                            
                                                            | 234 |  | -                } elseif (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']) && count($thumbConfig['fit']) === 3) { | 
                                                                                                            
                                                            | 235 |  | -                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig['fit'][0], $thumbConfig['fit'][1], $thumbConfig['fit'][2]); | 
                                                                                                            
                                                            | 236 |  | -                } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 1) { | 
                                                                                                            
                                                            | 237 |  | -                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0]); | 
                                                                                                            
                                                            | 238 |  | -                } elseif (isset($thumbConfig['square']) && is_array($thumbConfig['square']) && count($thumbConfig['square']) === 2) { | 
                                                                                                            
                                                            | 239 |  | -                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig['square'][0], $thumbConfig['square'][1]); | 
                                                                                                            
                                                            |  | 223 | +            foreach ($fileConfig[ 'thumbs' ] as $thumbName => $thumbConfig) { | 
                                                                                                            
                                                            |  | 224 | +                if (isset($thumbConfig[ 'width' ])) { | 
                                                                                                            
                                                            |  | 225 | +                    list($newWidth, $newHeight) = $this->getDimensionsByNewWidth($originalWidth, $originalHeight, $thumbConfig[ 'width' ]); | 
                                                                                                            
                                                            |  | 226 | +                } elseif (isset($thumbConfig[ 'height' ])) { | 
                                                                                                            
                                                            |  | 227 | +                    list($newWidth, $newHeight) = $this->getDimensionsByNewHeight($originalWidth, $originalHeight, $thumbConfig[ 'height' ]); | 
                                                                                                            
                                                            |  | 228 | +                } elseif (isset($thumbConfig[ 'shorter' ]) && is_array($thumbConfig[ 'shorter' ]) && count($thumbConfig[ 'shorter' ]) === 2) { | 
                                                                                                            
                                                            |  | 229 | +                    list($newWidth, $newHeight) = $this->getDimensionsByShorterSide($originalWidth, $originalHeight, $thumbConfig[ 'shorter' ][ 0 ], $thumbConfig[ 'shorter' ][ 1 ]); | 
                                                                                                            
                                                            |  | 230 | +                } elseif (isset($thumbConfig[ 'longer' ]) && is_array($thumbConfig[ 'longer' ]) && count($thumbConfig[ 'longer' ]) === 2) { | 
                                                                                                            
                                                            |  | 231 | +                    list($newWidth, $newHeight) = $this->getDimensionsByLongerSide($originalWidth, $originalHeight, $thumbConfig[ 'longer' ][ 0 ], $thumbConfig[ 'longer' ][ 1 ]); | 
                                                                                                            
                                                            |  | 232 | +                } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 2) { | 
                                                                                                            
                                                            |  | 233 | +                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ]); | 
                                                                                                            
                                                            |  | 234 | +                } elseif (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]) && count($thumbConfig[ 'fit' ]) === 3) { | 
                                                                                                            
                                                            |  | 235 | +                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFit($originalWidth, $originalHeight, $thumbConfig[ 'fit' ][ 0 ], $thumbConfig[ 'fit' ][ 1 ], $thumbConfig[ 'fit' ][ 2 ]); | 
                                                                                                            
                                                            |  | 236 | +                } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 1) { | 
                                                                                                            
                                                            |  | 237 | +                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ]); | 
                                                                                                            
                                                            |  | 238 | +                } elseif (isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ]) && count($thumbConfig[ 'square' ]) === 2) { | 
                                                                                                            
                                                            |  | 239 | +                    list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->getDimensionsByFitToSquare($originalWidth, $originalHeight, $thumbConfig[ 'square' ][ 0 ], $thumbConfig[ 'square' ][ 1 ]); | 
                                                                                                            
                                                            | 240 | 240 |                  } else { | 
                                                                                                            
                                                            | 241 | 241 |                      throw new ThumbsException(__d('file', 'Unknown type or incorrect parameters of creating thumbnails!')); | 
                                                                                                            
                                                            | 242 | 242 |                  } | 
                                                                                                            
                                                            | 243 | 243 |   | 
                                                                                                            
                                                            | 244 | 244 |                  $thumbFile = str_replace('default', $thumbName, $filePath); | 
                                                                                                            
                                                            | 245 | 245 |   | 
                                                                                                            
                                                            | 246 |  | -                switch ($fileConfig['library']) { | 
                                                                                                            
                                                            |  | 246 | +                switch ($fileConfig[ 'library' ]) { | 
                                                                                                            
                                                            | 247 | 247 |                      // Get image resource | 
                                                                                                            
                                                            | 248 | 248 |                      case 'gd': | 
                                                                                                            
                                                            | 249 | 249 |                          $newImage = imagecreatetruecolor($newWidth, $newHeight); | 
                                                                                                            
                                                            | 250 | 250 |   | 
                                                                                                            
                                                            | 251 |  | -                        if (is_array($fileConfig['background'])) { | 
                                                                                                            
                                                            |  | 251 | +                        if (is_array($fileConfig[ 'background' ])) { | 
                                                                                                            
                                                            | 252 | 252 |                              // Set background color and transparent indicates | 
                                                                                                            
                                                            | 253 |  | -                            imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); | 
                                                                                                            
                                                            |  | 253 | +                            imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); | 
                                                                                                            
                                                            | 254 | 254 |                          } | 
                                                                                                            
                                                            | 255 | 255 |   | 
                                                                                                            
                                                            | 256 | 256 |                          imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight); | 
                                                                                                            
                                                            | 257 | 257 |   | 
                                                                                                            
                                                            | 258 |  | -                        if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { | 
                                                                                                            
                                                            |  | 258 | +                        if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { | 
                                                                                                            
                                                            | 259 | 259 |                              $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY)); | 
                                                                                                            
                                                            | 260 | 260 |   | 
                                                                                                            
                                                            | 261 |  | -                            if (is_array($fileConfig['background'])) { | 
                                                                                                            
                                                            |  | 261 | +                            if (is_array($fileConfig[ 'background' ])) { | 
                                                                                                            
                                                            | 262 | 262 |                                  // Set background color and transparent indicates | 
                                                                                                            
                                                            | 263 |  | -                                imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig['background'][0], $fileConfig['background'][1], $fileConfig['background'][2], $fileConfig['background'][3])); | 
                                                                                                            
                                                            |  | 263 | +                                imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $fileConfig[ 'background' ][ 0 ], $fileConfig[ 'background' ][ 1 ], $fileConfig[ 'background' ][ 2 ], $fileConfig[ 'background' ][ 3 ])); | 
                                                                                                            
                                                            | 264 | 264 |                              } | 
                                                                                                            
                                                            | 265 | 265 |   | 
                                                                                                            
                                                            | 266 | 266 |                              imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight); | 
                                                                                                                                                        
                                                        |  | @@ -272,10 +272,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 272 | 272 |                          imagesavealpha($newImage, true); | 
                                                                                                            
                                                            | 273 | 273 |   | 
                                                                                                            
                                                            | 274 | 274 |                          // Watermark | 
                                                                                                            
                                                            | 275 |  | -                        if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { | 
                                                                                                            
                                                            |  | 275 | +                        if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { | 
                                                                                                            
                                                            | 276 | 276 |                              $watermarkImage = imagecreatefromstring($watermarkSource); | 
                                                                                                            
                                                            | 277 | 277 |   | 
                                                                                                            
                                                            | 278 |  | -                            list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig['watermark']); | 
                                                                                                            
                                                            |  | 278 | +                            list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); | 
                                                                                                            
                                                            | 279 | 279 |   | 
                                                                                                            
                                                            | 280 | 280 |                              // Set transparent | 
                                                                                                            
                                                            | 281 | 281 |                              imagealphablending($newImage, true); | 
                                                                                                                                                        
                                                        |  | @@ -314,16 +314,16 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 314 | 314 |                          $newImage->setimagebackgroundcolor('transparent'); | 
                                                                                                            
                                                            | 315 | 315 |                          $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY); | 
                                                                                                            
                                                            | 316 | 316 |   | 
                                                                                                            
                                                            | 317 |  | -                        if ((isset($thumbConfig['square']) && is_array($thumbConfig['square'])) || (isset($thumbConfig['fit']) && is_array($thumbConfig['fit']))) { | 
                                                                                                            
                                                            |  | 317 | +                        if ((isset($thumbConfig[ 'square' ]) && is_array($thumbConfig[ 'square' ])) || (isset($thumbConfig[ 'fit' ]) && is_array($thumbConfig[ 'fit' ]))) { | 
                                                                                                            
                                                            | 318 | 318 |                              $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY); | 
                                                                                                            
                                                            | 319 | 319 |                          } | 
                                                                                                            
                                                            | 320 | 320 |   | 
                                                                                                            
                                                            | 321 | 321 |                          // Watermark | 
                                                                                                            
                                                            | 322 |  | -                        if (isset($thumbConfig['watermark']) && ($watermarkSource = file_get_contents($fileConfig['watermark'])) !== false) { | 
                                                                                                            
                                                            |  | 322 | +                        if (isset($thumbConfig[ 'watermark' ]) && ($watermarkSource = file_get_contents($fileConfig[ 'watermark' ])) !== false) { | 
                                                                                                            
                                                            | 323 | 323 |                              $watermarkImage = new \Imagick(); | 
                                                                                                            
                                                            | 324 | 324 |                              $watermarkImage->readimageblob($watermarkSource); | 
                                                                                                            
                                                            | 325 | 325 |   | 
                                                                                                            
                                                            | 326 |  | -                            list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig['watermark']); | 
                                                                                                            
                                                            |  | 326 | +                            list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbConfig[ 'watermark' ]); | 
                                                                                                            
                                                            | 327 | 327 |   | 
                                                                                                            
                                                            | 328 | 328 |                              $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY); | 
                                                                                                            
                                                            | 329 | 329 |                          } | 
                                                                                                                                                        
                                                        |  | @@ -352,10 +352,10 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 352 | 352 |   | 
                                                                                                            
                                                            | 353 | 353 |          if (!empty($config)) { | 
                                                                                                            
                                                            | 354 | 354 |              foreach ($config as $file => $fileConfig) { | 
                                                                                                            
                                                            | 355 |  | -                if (isset($entity[$file])) { | 
                                                                                                            
                                                            | 356 |  | -                    $path = $fileConfig['path'] . DS . substr($entity[$file], 0, 37); | 
                                                                                                            
                                                            |  | 355 | +                if (isset($entity[ $file ])) { | 
                                                                                                            
                                                            |  | 356 | +                    $path = $fileConfig[ 'path' ].DS.substr($entity[ $file ], 0, 37); | 
                                                                                                            
                                                            | 357 | 357 |   | 
                                                                                                            
                                                            | 358 |  | -                    foreach (glob($path . '*') as $file) { | 
                                                                                                            
                                                            |  | 358 | +                    foreach (glob($path.'*') as $file) { | 
                                                                                                            
                                                            | 359 | 359 |                          if (file_exists($file)) { | 
                                                                                                            
                                                            | 360 | 360 |                              unlink($file); | 
                                                                                                            
                                                            | 361 | 361 |                          } | 
                                                                                                                                                        
                                                        |  | @@ -385,7 +385,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 385 | 385 |       */ | 
                                                                                                            
                                                            | 386 | 386 |      protected function setFile(string $file, UploadedFile $data): void | 
                                                                                                            
                                                            | 387 | 387 |      { | 
                                                                                                            
                                                            | 388 |  | -        $this->files[$file] = $data; | 
                                                                                                            
                                                            |  | 388 | +        $this->files[ $file ] = $data; | 
                                                                                                            
                                                            | 389 | 389 |      } | 
                                                                                                            
                                                            | 390 | 390 |   | 
                                                                                                            
                                                            | 391 | 391 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -426,7 +426,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 426 | 426 |       */ | 
                                                                                                            
                                                            | 427 | 427 |      protected function createName(string $name): string | 
                                                                                                            
                                                            | 428 | 428 |      { | 
                                                                                                            
                                                            | 429 |  | -        return Text::uuid() . '_default.' . $this->getExtension($name); | 
                                                                                                            
                                                            |  | 429 | +        return Text::uuid().'_default.'.$this->getExtension($name); | 
                                                                                                            
                                                            | 430 | 430 |      } | 
                                                                                                            
                                                            | 431 | 431 |   | 
                                                                                                            
                                                            | 432 | 432 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -471,43 +471,43 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 471 | 471 |      { | 
                                                                                                            
                                                            | 472 | 472 |          switch ($positionValue) { | 
                                                                                                            
                                                            | 473 | 473 |              case 1: // Top left | 
                                                                                                            
                                                            | 474 |  | -                return [$offsetX, $offsetY]; | 
                                                                                                            
                                                            |  | 474 | +                return [ $offsetX, $offsetY ]; | 
                                                                                                            
                                                            | 475 | 475 |   | 
                                                                                                            
                                                            | 476 | 476 |                  break; | 
                                                                                                            
                                                            | 477 | 477 |              case 2: // Top center | 
                                                                                                            
                                                            | 478 |  | -                return [($newWidth / 2) - ($watermarkWidth / 2), $offsetY]; | 
                                                                                                            
                                                            |  | 478 | +                return [ ($newWidth / 2) - ($watermarkWidth / 2), $offsetY ]; | 
                                                                                                            
                                                            | 479 | 479 |   | 
                                                                                                            
                                                            | 480 | 480 |                  break; | 
                                                                                                            
                                                            | 481 | 481 |              case 3: // Top right | 
                                                                                                            
                                                            | 482 |  | -                return [($newWidth - $watermarkWidth - $offsetX), $offsetY]; | 
                                                                                                            
                                                            |  | 482 | +                return [ ($newWidth - $watermarkWidth - $offsetX), $offsetY ]; | 
                                                                                                            
                                                            | 483 | 483 |   | 
                                                                                                            
                                                            | 484 | 484 |                  break; | 
                                                                                                            
                                                            | 485 | 485 |              case 4: // Middle left | 
                                                                                                            
                                                            | 486 |  | -                return [$offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; | 
                                                                                                            
                                                            |  | 486 | +                return [ $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | 
                                                                                                            
                                                            | 487 | 487 |   | 
                                                                                                            
                                                            | 488 | 488 |                  break; | 
                                                                                                            
                                                            | 489 | 489 |              case 5: // Middle center | 
                                                                                                            
                                                            | 490 |  | -                return [intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2))]; | 
                                                                                                            
                                                            |  | 490 | +                return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | 
                                                                                                            
                                                            | 491 | 491 |   | 
                                                                                                            
                                                            | 492 | 492 |                  break; | 
                                                                                                            
                                                            | 493 | 493 |              case 6: // Middle right | 
                                                                                                            
                                                            | 494 |  | -                return [($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2))]; | 
                                                                                                            
                                                            |  | 494 | +                return [ ($newWidth - $watermarkWidth) - $offsetX, intval(($newHeight / 2) - ($watermarkHeight / 2)) ]; | 
                                                                                                            
                                                            | 495 | 495 |   | 
                                                                                                            
                                                            | 496 | 496 |                  break; | 
                                                                                                            
                                                            | 497 | 497 |              case 7: // Bottom left | 
                                                                                                            
                                                            | 498 |  | -                return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | 
                                                                                                            
                                                            |  | 498 | +                return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | 
                                                                                                            
                                                            | 499 | 499 |   | 
                                                                                                            
                                                            | 500 | 500 |                  break; | 
                                                                                                            
                                                            | 501 | 501 |              case 8: // Bottom center | 
                                                                                                            
                                                            | 502 |  | -                return [intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY]; | 
                                                                                                            
                                                            |  | 502 | +                return [ intval(($newWidth / 2) - ($watermarkWidth / 2)), ($newHeight - $watermarkHeight) - $offsetY ]; | 
                                                                                                            
                                                            | 503 | 503 |   | 
                                                                                                            
                                                            | 504 | 504 |                  break; | 
                                                                                                            
                                                            | 505 | 505 |              case 9: // Bottom right | 
                                                                                                            
                                                            | 506 |  | -                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY]; | 
                                                                                                            
                                                            |  | 506 | +                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ]; | 
                                                                                                            
                                                            | 507 | 507 |   | 
                                                                                                            
                                                            | 508 | 508 |                  break; | 
                                                                                                            
                                                            | 509 | 509 |              default: | 
                                                                                                            
                                                            | 510 |  | -                return [$offsetX, $offsetY]; | 
                                                                                                            
                                                            |  | 510 | +                return [ $offsetX, $offsetY ]; | 
                                                                                                            
                                                            | 511 | 511 |   | 
                                                                                                            
                                                            | 512 | 512 |                  break; | 
                                                                                                            
                                                            | 513 | 513 |          } | 
                                                                                                                                                        
                                                        |  | @@ -530,7 +530,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 530 | 530 |              $newHeight = intval($newWidth * ($originalHeight / $originalWidth)); | 
                                                                                                            
                                                            | 531 | 531 |          } | 
                                                                                                            
                                                            | 532 | 532 |   | 
                                                                                                            
                                                            | 533 |  | -        return [$newWidth, $newHeight]; | 
                                                                                                            
                                                            |  | 533 | +        return [ $newWidth, $newHeight ]; | 
                                                                                                            
                                                            | 534 | 534 |      } | 
                                                                                                            
                                                            | 535 | 535 |   | 
                                                                                                            
                                                            | 536 | 536 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -550,7 +550,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 550 | 550 |              $newWidth = intval($newHeight * ($originalWidth / $originalHeight)); | 
                                                                                                            
                                                            | 551 | 551 |          } | 
                                                                                                            
                                                            | 552 | 552 |   | 
                                                                                                            
                                                            | 553 |  | -        return [$newWidth, $newHeight]; | 
                                                                                                            
                                                            |  | 553 | +        return [ $newWidth, $newHeight ]; | 
                                                                                                            
                                                            | 554 | 554 |      } | 
                                                                                                            
                                                            | 555 | 555 |   | 
                                                                                                            
                                                            | 556 | 556 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -570,7 +570,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 570 | 570 |              list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); | 
                                                                                                            
                                                            | 571 | 571 |          } | 
                                                                                                            
                                                            | 572 | 572 |   | 
                                                                                                            
                                                            | 573 |  | -        return [$newWidth, $newHeight]; | 
                                                                                                            
                                                            |  | 573 | +        return [ $newWidth, $newHeight ]; | 
                                                                                                            
                                                            | 574 | 574 |      } | 
                                                                                                            
                                                            | 575 | 575 |   | 
                                                                                                            
                                                            | 576 | 576 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -590,7 +590,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 590 | 590 |              list($newWidth, $newHeight) = self::getDimensionsByNewHeight($originalWidth, $originalHeight, $newHeight); | 
                                                                                                            
                                                            | 591 | 591 |          } | 
                                                                                                            
                                                            | 592 | 592 |   | 
                                                                                                            
                                                            | 593 |  | -        return [$newWidth, $newHeight]; | 
                                                                                                            
                                                            |  | 593 | +        return [ $newWidth, $newHeight ]; | 
                                                                                                            
                                                            | 594 | 594 |      } | 
                                                                                                            
                                                            | 595 | 595 |   | 
                                                                                                            
                                                            | 596 | 596 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -616,7 +616,7 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 616 | 616 |              } else { | 
                                                                                                            
                                                            | 617 | 617 |                  $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
                                                                                                            
                                                            | 618 | 618 |   | 
                                                                                                            
                                                            | 619 |  | -                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) { | 
                                                                                                            
                                                            |  | 619 | +                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) { | 
                                                                                                            
                                                            | 620 | 620 |                      $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
                                                                                                            
                                                            | 621 | 621 |                  } | 
                                                                                                            
                                                            | 622 | 622 |              } | 
                                                                                                                                                        
                                                        |  | @@ -626,25 +626,25 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 626 | 626 |              } else { | 
                                                                                                            
                                                            | 627 | 627 |                  $newSizes = self::getDimensionsByShorterSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
                                                                                                            
                                                            | 628 | 628 |   | 
                                                                                                            
                                                            | 629 |  | -                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) { | 
                                                                                                            
                                                            |  | 629 | +                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) { | 
                                                                                                            
                                                            | 630 | 630 |                      $newSizes = self::getDimensionsByLongerSide($originalWidth, $originalHeight, $newWidth, $newHeight); | 
                                                                                                            
                                                            | 631 | 631 |                  } | 
                                                                                                            
                                                            | 632 | 632 |              } | 
                                                                                                            
                                                            | 633 | 633 |          } | 
                                                                                                            
                                                            | 634 | 634 |   | 
                                                                                                            
                                                            | 635 |  | -        if ($newWidth < $newSizes[0]) { | 
                                                                                                            
                                                            | 636 |  | -            $cropX = ($newSizes[0] - $newWidth) / 2; | 
                                                                                                            
                                                            |  | 635 | +        if ($newWidth < $newSizes[ 0 ]) { | 
                                                                                                            
                                                            |  | 636 | +            $cropX = ($newSizes[ 0 ] - $newWidth) / 2; | 
                                                                                                            
                                                            | 637 | 637 |          } else { | 
                                                                                                            
                                                            | 638 |  | -            $offsetX = ($newWidth - $newSizes[0]) / 2; | 
                                                                                                            
                                                            |  | 638 | +            $offsetX = ($newWidth - $newSizes[ 0 ]) / 2; | 
                                                                                                            
                                                            | 639 | 639 |          } | 
                                                                                                            
                                                            | 640 | 640 |   | 
                                                                                                            
                                                            | 641 |  | -        if ($newHeight < $newSizes[1]) { | 
                                                                                                            
                                                            | 642 |  | -            $cropY = ($newSizes[1] - $newHeight) / 2; | 
                                                                                                            
                                                            |  | 641 | +        if ($newHeight < $newSizes[ 1 ]) { | 
                                                                                                            
                                                            |  | 642 | +            $cropY = ($newSizes[ 1 ] - $newHeight) / 2; | 
                                                                                                            
                                                            | 643 | 643 |          } else { | 
                                                                                                            
                                                            | 644 |  | -            $offsetY = ($newHeight - $newSizes[1]) / 2; | 
                                                                                                            
                                                            |  | 644 | +            $offsetY = ($newHeight - $newSizes[ 1 ]) / 2; | 
                                                                                                            
                                                            | 645 | 645 |          } | 
                                                                                                            
                                                            | 646 | 646 |   | 
                                                                                                            
                                                            | 647 |  | -        return [$newSizes[0], $newSizes[1], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; | 
                                                                                                            
                                                            |  | 647 | +        return [ $newSizes[ 0 ], $newSizes[ 1 ], intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; | 
                                                                                                            
                                                            | 648 | 648 |      } | 
                                                                                                            
                                                            | 649 | 649 |   | 
                                                                                                            
                                                            | 650 | 650 |      /** | 
                                                                                                                                                        
                                                        |  | @@ -689,6 +689,6 @@  discard block | 
                                                    
                                                        |  |  |  block discarded – undo | 
                                                                                                                                                                                                                    
                                                            | 689 | 689 |              } | 
                                                                                                            
                                                            | 690 | 690 |          } | 
                                                                                                            
                                                            | 691 | 691 |   | 
                                                                                                            
                                                            | 692 |  | -        return [$newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY)]; | 
                                                                                                            
                                                            |  | 692 | +        return [ $newWidth, $newHeight, intval($offsetX), intval($offsetY), intval($cropX), intval($cropY) ]; | 
                                                                                                            
                                                            | 693 | 693 |      } | 
                                                                                                            
                                                            | 694 | 694 |  } | 
                                                                                                            
                                                            | 695 | 695 | \ No newline at end of file |