Passed
Push — master ( 7cf731...2ee09d )
by kicaj
04:27 queued 01:47
created
src/Model/Behavior/FileBehavior.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
             'webp',
37 37
         ],
38 38
         'path' => 'files',
39
-        'background' => [255, 255, 255, 127],
39
+        'background' => [ 255, 255, 255, 127 ],
40 40
         'watermark' => '',
41
-        'thumbs' => [],
41
+        'thumbs' => [ ],
42 42
     ];
43 43
 
44 44
     /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
      *
47 47
      * @var array
48 48
      */
49
-    protected $_files = [];
49
+    protected $_files = [ ];
50 50
 
51 51
     /**
52 52
      * {@inheritDoc}
53 53
      */
54 54
     public function initialize(array $config)
55 55
     {
56
-        $this->_config = [];
56
+        $this->_config = [ ];
57 57
 
58 58
         foreach ($config as $field => $fieldOptions) {
59 59
             if (is_array($fieldOptions)) {
60
-                $this->_config[$this->getTable()->getAlias()][$field] = array_merge($this->_defaultConfig, $fieldOptions);
60
+                $this->_config[ $this->getTable()->getAlias() ][ $field ] = array_merge($this->_defaultConfig, $fieldOptions);
61 61
             } else {
62 62
                 $field = $fieldOptions;
63 63
 
64
-                $this->_config[$this->getTable()->getAlias()][$field] = $this->_defaultConfig;
64
+                $this->_config[ $this->getTable()->getAlias() ][ $field ] = $this->_defaultConfig;
65 65
             }
66 66
         }
67 67
     }
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
     /**
70 70
      * {@inheritDoc}
71 71
      */
72
-    public function beforeMarshal(Event $event, $data = [], $options = [])
72
+    public function beforeMarshal(Event $event, $data = [ ], $options = [ ])
73 73
     {
74
-        if (!empty($config = $this->_config[$this->getTable()->getAlias()])) {
74
+        if (!empty($config = $this->_config[ $this->getTable()->getAlias() ])) {
75 75
             foreach ($config as $field => $fieldOptions) {
76 76
                 // Check for temporary file
77
-                if (isset($data[$field]) && !empty($data[$field]['name']) && file_exists($data[$field]['tmp_name'])) {
77
+                if (isset($data[ $field ]) && !empty($data[ $field ][ 'name' ]) && file_exists($data[ $field ][ 'tmp_name' ])) {
78 78
                     // Create archive file data with suffix on original field name
79 79
                     // @todo Create only when field name is used in database
80
-                    $data['_' . $field] = $data[$field];
80
+                    $data[ '_'.$field ] = $data[ $field ];
81 81
 
82
-                    $this->_files[$field] = $data[$field];
83
-                    $this->_files[$field]['path'] = $this->_prepareDir($fieldOptions['path']);
84
-                    $this->_files[$field]['name'] = $this->_prepareName($data, $field);
82
+                    $this->_files[ $field ] = $data[ $field ];
83
+                    $this->_files[ $field ][ 'path' ] = $this->_prepareDir($fieldOptions[ 'path' ]);
84
+                    $this->_files[ $field ][ 'name' ] = $this->_prepareName($data, $field);
85 85
 
86
-                    $data[$field] = $this->_files[$field]['name'];
86
+                    $data[ $field ] = $this->_files[ $field ][ 'name' ];
87 87
                 } else {
88
-                    if (isset($data[$field]) && is_array($data[$field])) {
88
+                    if (isset($data[ $field ]) && is_array($data[ $field ])) {
89 89
                         // Delete file array from data when is not attached
90
-                        unset($data[$field]);
90
+                        unset($data[ $field ]);
91 91
                     }
92 92
                 }
93 93
             }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      * {@inheritDoc}
99 99
      */
100
-    public function afterSave(Event $event, EntityInterface $entity, $options = [])
100
+    public function afterSave(Event $event, EntityInterface $entity, $options = [ ])
101 101
     {
102 102
         $this->prepareFile($entity);
103 103
     }
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
     {
120 120
         foreach ($this->_files as $fieldName => $fieldOptions) {
121 121
             // Path to default file
122
-            $fileName = $fieldOptions['path'] . DS . $this->_files[$fieldName]['name'];
122
+            $fileName = $fieldOptions[ 'path' ].DS.$this->_files[ $fieldName ][ 'name' ];
123 123
 
124
-            if (move_uploaded_file($this->_files[$fieldName]['tmp_name'], $fileName) || (file_exists($this->_files[$fieldName]['tmp_name']) && rename($this->_files[$fieldName]['tmp_name'], $fileName))) {
125
-                if (isset($this->_files[$fieldName]['type']) && mb_strpos($this->_files[$fieldName]['type'], 'image/') !== false && in_array(mb_strtolower($this->_files[$fieldName]['type']), $this->_config[$this->getTable()->getAlias()][$fieldName]['types'])) {
126
-                    $this->prepareThumbs($fileName, $this->_config[$this->getTable()->getAlias()][$fieldName]);
124
+            if (move_uploaded_file($this->_files[ $fieldName ][ 'tmp_name' ], $fileName) || (file_exists($this->_files[ $fieldName ][ 'tmp_name' ]) && rename($this->_files[ $fieldName ][ 'tmp_name' ], $fileName))) {
125
+                if (isset($this->_files[ $fieldName ][ 'type' ]) && mb_strpos($this->_files[ $fieldName ][ 'type' ], 'image/') !== false && in_array(mb_strtolower($this->_files[ $fieldName ][ 'type' ]), $this->_config[ $this->getTable()->getAlias() ][ $fieldName ][ 'types' ])) {
126
+                    $this->prepareThumbs($fileName, $this->_config[ $this->getTable()->getAlias() ][ $fieldName ]);
127 127
                 }
128 128
             }
129 129
         }
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
         // Get field list of model schema
141 141
         $modelSchema = $model->schema();
142 142
 
143
-        foreach ($this->settings[$model->alias] as $fieldName => $fieldOptions) {
143
+        foreach ($this->settings[ $model->alias ] as $fieldName => $fieldOptions) {
144 144
             // Check is field in model schema
145
-            if (isset($modelSchema[$fieldName])) {
145
+            if (isset($modelSchema[ $fieldName ])) {
146 146
                 $dataField = $model->findById($model->id);
147 147
 
148
-                if (is_array($dataField) && !empty($dataField[$model->alias][$fieldName])) {
148
+                if (is_array($dataField) && !empty($dataField[ $model->alias ][ $fieldName ])) {
149 149
                     // Pattern for original file with thumbs
150
-                    $filePattern = $this->settings[$model->alias][$fieldName]['path'] . DS . substr($dataField[$model->alias][$fieldName], 0, 14);
150
+                    $filePattern = $this->settings[ $model->alias ][ $fieldName ][ 'path' ].DS.substr($dataField[ $model->alias ][ $fieldName ], 0, 14);
151 151
 
152
-                    foreach (glob($filePattern . '*') as $fileName) {
152
+                    foreach (glob($filePattern.'*') as $fileName) {
153 153
                         // Remove file
154 154
                         @unlink($fileName);
155 155
                     }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
     {
172 172
         if (is_file($originalFile) && is_array($settingParams)) {
173 173
             // Check image library
174
-            if (!extension_loaded($settingParams['library'])) {
175
-                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams['library']));
174
+            if (!extension_loaded($settingParams[ 'library' ])) {
175
+                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams[ 'library' ]));
176 176
             }
177 177
 
178 178
             // Get extension from original file
179 179
             $fileExtension = $this->getExtension($originalFile);
180 180
 
181
-            switch ($settingParams['library']) {
181
+            switch ($settingParams[ 'library' ]) {
182 182
                 // Get image resource
183 183
                 case 'gd':
184 184
                     switch ($fileExtension) {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 
217 217
                     break;
218 218
                 default:
219
-                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams['library']));
219
+                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams[ 'library' ]));
220 220
             }
221 221
 
222 222
             $offsetX = 0;
@@ -225,48 +225,48 @@  discard block
 block discarded – undo
225 225
             $cropX = 0;
226 226
             $cropY = 0;
227 227
 
228
-            foreach ($settingParams['thumbs'] as $thumbName => $thumbParam) {
228
+            foreach ($settingParams[ 'thumbs' ] as $thumbName => $thumbParam) {
229 229
                 if (is_array($thumbParam)) {
230
-                    if (isset($thumbParam['width']) && is_array($thumbParam['width']) && count($thumbParam['width']) === 1) {
231
-                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam['width'][0]);
232
-                    } elseif (isset($thumbParam['height']) && is_array($thumbParam['height']) && count($thumbParam['height']) === 1) {
233
-                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam['height'][0]);
234
-                    } elseif (isset($thumbParam['shorter']) && is_array($thumbParam['shorter']) && count($thumbParam['shorter']) === 2) {
235
-                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam['shorter'][0], $thumbParam['shorter'][1]);
236
-                    } elseif (isset($thumbParam['longer']) && is_array($thumbParam['longer']) && count($thumbParam['longer']) === 2) {
237
-                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam['longer'][0], $thumbParam['longer'][1]);
238
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 2) {
239
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1]);
240
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 3) {
241
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1], $thumbParam['fit'][2]);
242
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 1) {
243
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0]);
244
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 2) {
245
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0], $thumbParam['square'][1]);
230
+                    if (isset($thumbParam[ 'width' ]) && is_array($thumbParam[ 'width' ]) && count($thumbParam[ 'width' ]) === 1) {
231
+                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam[ 'width' ][ 0 ]);
232
+                    } elseif (isset($thumbParam[ 'height' ]) && is_array($thumbParam[ 'height' ]) && count($thumbParam[ 'height' ]) === 1) {
233
+                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam[ 'height' ][ 0 ]);
234
+                    } elseif (isset($thumbParam[ 'shorter' ]) && is_array($thumbParam[ 'shorter' ]) && count($thumbParam[ 'shorter' ]) === 2) {
235
+                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam[ 'shorter' ][ 0 ], $thumbParam[ 'shorter' ][ 1 ]);
236
+                    } elseif (isset($thumbParam[ 'longer' ]) && is_array($thumbParam[ 'longer' ]) && count($thumbParam[ 'longer' ]) === 2) {
237
+                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam[ 'longer' ][ 0 ], $thumbParam[ 'longer' ][ 1 ]);
238
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 2) {
239
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ]);
240
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 3) {
241
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ], $thumbParam[ 'fit' ][ 2 ]);
242
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 1) {
243
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ]);
244
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 2) {
245
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ], $thumbParam[ 'square' ][ 1 ]);
246 246
                     } else {
247 247
                         throw new ThumbsException(__d('file', 'Unknown type of creating thumbnails!'));
248 248
                     }
249 249
 
250 250
                     $thumbFile = str_replace('default', $thumbName, $originalFile);
251 251
 
252
-                    switch ($settingParams['library']) {
252
+                    switch ($settingParams[ 'library' ]) {
253 253
                         // Get image resource
254 254
                         case 'gd':
255 255
                             $newImage = imagecreatetruecolor($newWidth, $newHeight);
256 256
 
257
-                            if (is_array($settingParams['background'])) {
257
+                            if (is_array($settingParams[ 'background' ])) {
258 258
                                 // Set background color and transparent indicates
259
-                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
259
+                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
260 260
                             }
261 261
 
262 262
                             imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
263 263
 
264
-                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) {
264
+                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) {
265 265
                                 $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY));
266 266
 
267
-                                if (is_array($settingParams['background'])) {
267
+                                if (is_array($settingParams[ 'background' ])) {
268 268
                                     // Set background color and transparent indicates
269
-                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
269
+                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
270 270
                                 }
271 271
 
272 272
                                 imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight);
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
                             imagesavealpha($newImage, true);
279 279
 
280 280
                             // Watermark
281
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
281
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
282 282
                                 $watermarkImage = imagecreatefromstring($watermarkSource);
283 283
 
284
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam['watermark']);
284
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
285 285
 
286 286
                                 // Set transparent
287 287
                                 imagealphablending($newImage, true);
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
                             $newImage->setimagebackgroundcolor('transparent');
317 317
                             $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY);
318 318
 
319
-                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) {
319
+                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) {
320 320
                                 $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY);
321 321
                             }
322 322
 
323 323
                             // Watermark
324
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
324
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
325 325
                                 $watermarkImage = new \Imagick();
326 326
                                 $watermarkImage->readimageblob($watermarkSource);
327 327
 
328
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam['watermark']);
328
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
329 329
 
330 330
                                 $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY);
331 331
                             }
@@ -402,43 +402,43 @@  discard block
 block discarded – undo
402 402
     {
403 403
         switch (intval($positionValue)) {
404 404
             case 1: // Top left
405
-                return [$offsetX, $offsetY];
405
+                return [ $offsetX, $offsetY ];
406 406
 
407 407
                 break;
408 408
             case 2: // Top center
409
-                return [($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY];
409
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY ];
410 410
 
411 411
                 break;
412 412
             case 3: // Top right
413
-                return [($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY];
413
+                return [ ($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY ];
414 414
 
415 415
                 break;
416 416
             case 4: // Middle left
417
-                return [$offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
417
+                return [ $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
418 418
 
419 419
                 break;
420 420
             case 5: // Middle center
421
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2)];
421
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2) ];
422 422
 
423 423
                 break;
424 424
             case 6: // Middle right
425
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
425
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
426 426
 
427 427
                 break;
428 428
             case 7: // Bottom left
429
-                return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY];
429
+                return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
430 430
 
431 431
                 break;
432 432
             case 8: // Bottom center
433
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY];
433
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY ];
434 434
 
435 435
                 break;
436 436
             case 9: // Bottom right
437
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY];
437
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
438 438
 
439 439
                 break;
440 440
             default:
441
-                return [$offsetX, $offsetY];
441
+                return [ $offsetX, $offsetY ];
442 442
 
443 443
                 break;
444 444
         }
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
      */
457 457
     protected function _prepareName($data, $fieldName)
458 458
     {
459
-        $name = Text::uuid() . '_default.' . $this->getExtension($this->_files[$fieldName]['name']);
459
+        $name = Text::uuid().'_default.'.$this->getExtension($this->_files[ $fieldName ][ 'name' ]);
460 460
 
461 461
         return $name;
462 462
     }
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
      */
471 471
     protected function _prepareDir($dirPath)
472 472
     {
473
-        $dirPath = WWW_ROOT . str_replace('/', DS, $dirPath);
473
+        $dirPath = WWW_ROOT.str_replace('/', DS, $dirPath);
474 474
 
475 475
         if (!is_dir($dirPath) && mb_strlen($dirPath) > 0) {
476 476
             mkdir($dirPath, 0777, true);
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             $newHeight = intval($newWidth * ($originalHeight / $originalWidth));
501 501
         }
502 502
 
503
-        return [$newWidth, $newHeight];
503
+        return [ $newWidth, $newHeight ];
504 504
     }
505 505
 
506 506
     /**
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
             $newWidth = intval($newHeight * ($originalWidth / $originalHeight));
523 523
         }
524 524
 
525
-        return [$newWidth, $newHeight];
525
+        return [ $newWidth, $newHeight ];
526 526
     }
527 527
 
528 528
     /**
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
546 546
         }
547 547
 
548
-        return [$newWidth, $newHeight];
548
+        return [ $newWidth, $newHeight ];
549 549
     }
550 550
 
551 551
     /**
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
569 569
         }
570 570
 
571
-        return [$newWidth, $newHeight];
571
+        return [ $newWidth, $newHeight ];
572 572
     }
573 573
 
574 574
     /**
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
             } else {
598 598
                 $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
599 599
 
600
-                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) {
600
+                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) {
601 601
                     $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
602 602
                 }
603 603
             }
@@ -607,25 +607,25 @@  discard block
 block discarded – undo
607 607
             } else {
608 608
                 $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
609 609
 
610
-                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) {
610
+                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) {
611 611
                     $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
612 612
                 }
613 613
             }
614 614
         }
615 615
 
616
-        if ($newWidth < $newSizes[0]) {
617
-            $cropX = ($newSizes[0] - $newWidth) / 2;
616
+        if ($newWidth < $newSizes[ 0 ]) {
617
+            $cropX = ($newSizes[ 0 ] - $newWidth) / 2;
618 618
         } else {
619
-            $offsetX = ($newWidth - $newSizes[0]) / 2;
619
+            $offsetX = ($newWidth - $newSizes[ 0 ]) / 2;
620 620
         }
621 621
 
622
-        if ($newHeight < $newSizes[1]) {
623
-            $cropY = ($newSizes[1] - $newHeight) / 2;
622
+        if ($newHeight < $newSizes[ 1 ]) {
623
+            $cropY = ($newSizes[ 1 ] - $newHeight) / 2;
624 624
         } else {
625
-            $offsetY = ($newHeight - $newSizes[1]) / 2;
625
+            $offsetY = ($newHeight - $newSizes[ 1 ]) / 2;
626 626
         }
627 627
 
628
-        return [$newSizes[0], $newSizes[1], $offsetX, $offsetY, $cropX, $cropY];
628
+        return [ $newSizes[ 0 ], $newSizes[ 1 ], $offsetX, $offsetY, $cropX, $cropY ];
629 629
     }
630 630
 
631 631
     /**
@@ -672,6 +672,6 @@  discard block
 block discarded – undo
672 672
             }
673 673
         }
674 674
 
675
-        return [$newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY];
675
+        return [ $newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY ];
676 676
     }
677 677
 }
678 678
\ No newline at end of file
Please login to merge, or discard this patch.
src/View/Helper/FileHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,14 +22,14 @@
 block discarded – undo
22 22
      * @return string completed img tag
23 23
      * @see https://book.cakephp.org/3.0/en/views/helpers/html.html#linking-to-images
24 24
      */
25
-    public function thumb($path, $options = [], $thumb = 'default')
25
+    public function thumb($path, $options = [ ], $thumb = 'default')
26 26
     {
27 27
         if ($thumb !== 'default') {
28 28
             $path = preg_replace('/default/', $thumb, $path);
29 29
         }
30 30
 
31 31
         if (!is_array($options)) {
32
-            $options = [];
32
+            $options = [ ];
33 33
         }
34 34
 
35 35
         return $this->Html->image($path, $options);
Please login to merge, or discard this patch.