Passed
Push — master ( 17bd36...983744 )
by kicaj
03:01
created
src/Model/Behavior/FileBehavior.php 1 patch
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
             'webp',
36 36
         ],
37 37
         'path' => 'files',
38
-        'background' => [255, 255, 255, 127],
38
+        'background' => [ 255, 255, 255, 127 ],
39 39
         'watermark' => '',
40
-        'thumbs' => [],
40
+        'thumbs' => [ ],
41 41
     ];
42 42
 
43 43
     /**
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      *
46 46
      * @var array
47 47
      */
48
-    protected $_files = [];
48
+    protected $_files = [ ];
49 49
 
50 50
     /**
51 51
      * @inheritdoc
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
     public function initialize(array $config)
54 54
     {
55 55
         foreach ($config as $field => $fieldOptions) {
56
-            $this->_config = [];
56
+            $this->_config = [ ];
57 57
 
58 58
             if (is_array($fieldOptions)) {
59
-                $this->_config[$this->_table->getAlias()][$field] = array_merge($this->_defaultConfig, $fieldOptions);
59
+                $this->_config[ $this->_table->getAlias() ][ $field ] = array_merge($this->_defaultConfig, $fieldOptions);
60 60
             } else {
61 61
                 $field = $fieldOptions;
62 62
 
63
-                $this->_config[$this->_table->getAlias()][$field] = $this->_defaultConfig;
63
+                $this->_config[ $this->_table->getAlias() ][ $field ] = $this->_defaultConfig;
64 64
             }
65 65
         }
66 66
     }
@@ -68,25 +68,25 @@  discard block
 block discarded – undo
68 68
     /**
69 69
      * @inheritdoc
70 70
      */
71
-    public function beforeMarshal(Event $event, $data = [], $options = [])
71
+    public function beforeMarshal(Event $event, $data = [ ], $options = [ ])
72 72
     {
73
-        if (!empty($config = $this->_config[$this->_table->getAlias()])) {
73
+        if (!empty($config = $this->_config[ $this->_table->getAlias() ])) {
74 74
             foreach ($config as $field => $fieldOptions) {
75 75
                 // Check for temporary file
76
-                if (isset($data[$field]) && !empty($data[$field]['name']) && file_exists($data[$field]['tmp_name'])) {
76
+                if (isset($data[ $field ]) && !empty($data[ $field ][ 'name' ]) && file_exists($data[ $field ][ 'tmp_name' ])) {
77 77
                     // Create archive file data with suffix on original field name
78 78
                     // @todo Create only when field name is used in database
79
-                    $data['_' . $field] = $data[$field];
79
+                    $data[ '_'.$field ] = $data[ $field ];
80 80
 
81
-                    $this->_files[$field] = $data[$field];
82
-                    $this->_files[$field]['path'] = $this->_prepareDir($fieldOptions['path']);
83
-                    $this->_files[$field]['name'] = $this->_prepareName($data, $field);
81
+                    $this->_files[ $field ] = $data[ $field ];
82
+                    $this->_files[ $field ][ 'path' ] = $this->_prepareDir($fieldOptions[ 'path' ]);
83
+                    $this->_files[ $field ][ 'name' ] = $this->_prepareName($data, $field);
84 84
 
85
-                    $data[$field] = $this->_files[$field]['name'];
85
+                    $data[ $field ] = $this->_files[ $field ][ 'name' ];
86 86
                 } else {
87
-                    if (isset($data[$field]) && is_array($data[$field])) {
87
+                    if (isset($data[ $field ]) && is_array($data[ $field ])) {
88 88
                         // Delete file array from data when is not attached
89
-                        unset($data[$field]);
89
+                        unset($data[ $field ]);
90 90
                     }
91 91
                 }
92 92
             }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     /**
97 97
      * @inheritdoc
98 98
      */
99
-    public function afterSave(Event $event, EntityInterface $entity, $options = [])
99
+    public function afterSave(Event $event, EntityInterface $entity, $options = [ ])
100 100
     {
101 101
         //if ($created !== true && empty($this->_files)) {
102 102
 
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
     {
123 123
         foreach ($this->_files as $fieldName => $fieldOptions) {
124 124
             // Path to default file
125
-            $fileName = $fieldOptions['path'] . DS . $this->_files[$fieldName]['name'];
125
+            $fileName = $fieldOptions[ 'path' ].DS.$this->_files[ $fieldName ][ 'name' ];
126 126
 
127
-            if (move_uploaded_file($this->_files[$fieldName]['tmp_name'], $fileName) || rename($this->_files[$fieldName]['tmp_name'], $fileName)) {
128
-                if (isset($this->_config[$this->_table->getAlias()][$fieldName]['thumbs'])) {
129
-                    $this->prepareThumbs($fileName, $this->_config[$this->_table->getAlias()][$fieldName]);
127
+            if (move_uploaded_file($this->_files[ $fieldName ][ 'tmp_name' ], $fileName) || rename($this->_files[ $fieldName ][ 'tmp_name' ], $fileName)) {
128
+                if (isset($this->_config[ $this->_table->getAlias() ][ $fieldName ][ 'thumbs' ])) {
129
+                    $this->prepareThumbs($fileName, $this->_config[ $this->_table->getAlias() ][ $fieldName ]);
130 130
                 }
131 131
             }
132 132
         }
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
         // Get field list of model schema
144 144
         $modelSchema = $model->schema();
145 145
 
146
-        foreach ($this->settings[$model->alias] as $fieldName => $fieldOptions) {
146
+        foreach ($this->settings[ $model->alias ] as $fieldName => $fieldOptions) {
147 147
             // Check is field in model schema
148
-            if (isset($modelSchema[$fieldName])) {
148
+            if (isset($modelSchema[ $fieldName ])) {
149 149
                 $dataField = $model->findById($model->id);
150 150
 
151
-                if (is_array($dataField) && !empty($dataField[$model->alias][$fieldName])) {
151
+                if (is_array($dataField) && !empty($dataField[ $model->alias ][ $fieldName ])) {
152 152
                     // Pattern for original file with thumbs
153
-                    $filePattern = $this->settings[$model->alias][$fieldName]['path'] . DS . substr($dataField[$model->alias][$fieldName], 0, 14);
153
+                    $filePattern = $this->settings[ $model->alias ][ $fieldName ][ 'path' ].DS.substr($dataField[ $model->alias ][ $fieldName ], 0, 14);
154 154
 
155
-                    foreach (glob($filePattern . '*') as $fileName) {
155
+                    foreach (glob($filePattern.'*') as $fileName) {
156 156
                         // Remove file
157 157
                         @unlink($fileName);
158 158
                     }
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
     {
175 175
         if (is_file($originalFile) && is_array($settingParams)) {
176 176
             // Check image library
177
-            if (!extension_loaded($settingParams['library'])) {
178
-                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams['library']));
177
+            if (!extension_loaded($settingParams[ 'library' ])) {
178
+                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams[ 'library' ]));
179 179
             }
180 180
 
181 181
             // Get extension from original file
182 182
             $fileExtension = $this->getExtension($originalFile);
183 183
 
184
-            switch ($settingParams['library']) {
184
+            switch ($settingParams[ 'library' ]) {
185 185
                 // Get image resource
186 186
                 case 'gd':
187 187
                     switch ($fileExtension) {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 
220 220
                     break;
221 221
                 default:
222
-                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams['library']));
222
+                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams[ 'library' ]));
223 223
             }
224 224
 
225 225
             $offsetX = 0;
@@ -228,48 +228,48 @@  discard block
 block discarded – undo
228 228
             $cropX = 0;
229 229
             $cropY = 0;
230 230
 
231
-            foreach ($settingParams['thumbs'] as $thumbName => $thumbParam) {
231
+            foreach ($settingParams[ 'thumbs' ] as $thumbName => $thumbParam) {
232 232
                 if (is_array($thumbParam)) {
233
-                    if (isset($thumbParam['width']) && is_array($thumbParam['width']) && count($thumbParam['width']) === 1) {
234
-                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam['width'][0]);
235
-                    } elseif (isset($thumbParam['height']) && is_array($thumbParam['height']) && count($thumbParam['height']) === 1) {
236
-                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam['height'][0]);
237
-                    } elseif (isset($thumbParam['shorter']) && is_array($thumbParam['shorter']) && count($thumbParam['shorter']) === 2) {
238
-                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam['shorter'][0], $thumbParam['shorter'][1]);
239
-                    } elseif (isset($thumbParam['longer']) && is_array($thumbParam['longer']) && count($thumbParam['longer']) === 2) {
240
-                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam['longer'][0], $thumbParam['longer'][1]);
241
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 2) {
242
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1]);
243
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 3) {
244
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1], $thumbParam['fit'][2]);
245
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 1) {
246
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0]);
247
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 2) {
248
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0], $thumbParam['square'][1]);
233
+                    if (isset($thumbParam[ 'width' ]) && is_array($thumbParam[ 'width' ]) && count($thumbParam[ 'width' ]) === 1) {
234
+                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam[ 'width' ][ 0 ]);
235
+                    } elseif (isset($thumbParam[ 'height' ]) && is_array($thumbParam[ 'height' ]) && count($thumbParam[ 'height' ]) === 1) {
236
+                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam[ 'height' ][ 0 ]);
237
+                    } elseif (isset($thumbParam[ 'shorter' ]) && is_array($thumbParam[ 'shorter' ]) && count($thumbParam[ 'shorter' ]) === 2) {
238
+                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam[ 'shorter' ][ 0 ], $thumbParam[ 'shorter' ][ 1 ]);
239
+                    } elseif (isset($thumbParam[ 'longer' ]) && is_array($thumbParam[ 'longer' ]) && count($thumbParam[ 'longer' ]) === 2) {
240
+                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam[ 'longer' ][ 0 ], $thumbParam[ 'longer' ][ 1 ]);
241
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 2) {
242
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ]);
243
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 3) {
244
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ], $thumbParam[ 'fit' ][ 2 ]);
245
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 1) {
246
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ]);
247
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 2) {
248
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ], $thumbParam[ 'square' ][ 1 ]);
249 249
                     } else {
250 250
                         throw new ThumbsException(__d('file', 'Unknown type of creating thumbnails!'));
251 251
                     }
252 252
 
253 253
                     $thumbFile = str_replace('default', $thumbName, $originalFile);
254 254
 
255
-                    switch ($settingParams['library']) {
255
+                    switch ($settingParams[ 'library' ]) {
256 256
                         // Get image resource
257 257
                         case 'gd':
258 258
                             $newImage = imagecreatetruecolor($newWidth, $newHeight);
259 259
 
260
-                            if (is_array($settingParams['background'])) {
260
+                            if (is_array($settingParams[ 'background' ])) {
261 261
                                 // Set background color and transparent indicates
262
-                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
262
+                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
263 263
                             }
264 264
 
265 265
                             imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
266 266
 
267
-                            if (isset($thumbParam['square']) && is_array($thumbParam['square']) || isset($thumbParam['fit']) && is_array($thumbParam['fit'])) {
267
+                            if (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) || isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ])) {
268 268
                                 $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY));
269 269
 
270
-                                if (is_array($settingParams['background'])) {
270
+                                if (is_array($settingParams[ 'background' ])) {
271 271
                                     // Set background color and transparent indicates
272
-                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
272
+                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
273 273
                                 }
274 274
 
275 275
                                 imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight);
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
                             imagesavealpha($newImage, true);
282 282
 
283 283
                             // Watermark
284
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
284
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
285 285
                                 $watermarkImage = imagecreatefromstring($watermarkSource);
286 286
 
287
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam['watermark']);
287
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
288 288
 
289 289
                                 // Set transparent
290 290
                                 imagealphablending($newImage, true);
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
                             $newImage->setimagebackgroundcolor('transparent');
320 320
                             $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY);
321 321
 
322
-                            if (isset($thumbParam['square']) && is_array($thumbParam['square']) || isset($thumbParam['fit']) && is_array($thumbParam['fit'])) {
322
+                            if (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) || isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ])) {
323 323
                                 $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY);
324 324
                             }
325 325
 
326 326
                             // Watermark
327
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
327
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
328 328
                                 $watermarkImage = new \Imagick();
329 329
                                 $watermarkImage->readimageblob($watermarkSource);
330 330
 
331
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam['watermark']);
331
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
332 332
 
333 333
                                 $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY);
334 334
                             }
@@ -407,43 +407,43 @@  discard block
 block discarded – undo
407 407
     {
408 408
         switch (intval($positionValue)) {
409 409
             case 1: // Top left
410
-                return [$offsetX, $offsetY];
410
+                return [ $offsetX, $offsetY ];
411 411
 
412 412
                 break;
413 413
             case 2: // Top center
414
-                return [($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY];
414
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY ];
415 415
 
416 416
                 break;
417 417
             case 3: // Top right
418
-                return [($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY];
418
+                return [ ($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY ];
419 419
 
420 420
                 break;
421 421
             case 4: // Middle left
422
-                return [$offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
422
+                return [ $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
423 423
 
424 424
                 break;
425 425
             case 5: // Middle center
426
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2)];
426
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2) ];
427 427
 
428 428
                 break;
429 429
             case 6: // Middle right
430
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
430
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
431 431
 
432 432
                 break;
433 433
             case 7: // Bottom left
434
-                return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY];
434
+                return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
435 435
 
436 436
                 break;
437 437
             case 8: // Bottom center
438
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY];
438
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY ];
439 439
 
440 440
                 break;
441 441
             case 9: // Bottom right
442
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY];
442
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
443 443
 
444 444
                 break;
445 445
             default:
446
-                return [$offsetX, $offsetY];
446
+                return [ $offsetX, $offsetY ];
447 447
 
448 448
                 break;
449 449
         }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
      */
462 462
     protected function _prepareName($data, $fieldName)
463 463
     {
464
-        $name = Text::uuid() . '_default.' . $this->getExtension($this->_files[$fieldName]['name']);
464
+        $name = Text::uuid().'_default.'.$this->getExtension($this->_files[ $fieldName ][ 'name' ]);
465 465
 
466 466
         return $name;
467 467
     }
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
      */
476 476
     protected function _prepareDir($dirPath)
477 477
     {
478
-        $dirPath = WWW_ROOT . str_replace('/', DS, $dirPath);
478
+        $dirPath = WWW_ROOT.str_replace('/', DS, $dirPath);
479 479
 
480 480
         if (!is_dir($dirPath) && mb_strlen($dirPath) > 0) {
481 481
             mkdir($dirPath, 0777, true);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
             $newHeight = intval($newWidth * ($originalHeight / $originalWidth));
506 506
         }
507 507
 
508
-        return [$newWidth, $newHeight];
508
+        return [ $newWidth, $newHeight ];
509 509
     }
510 510
 
511 511
     /**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             $newWidth = intval($newHeight * ($originalWidth / $originalHeight));
528 528
         }
529 529
 
530
-        return [$newWidth, $newHeight];
530
+        return [ $newWidth, $newHeight ];
531 531
     }
532 532
 
533 533
     /**
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
551 551
         }
552 552
 
553
-        return [$newWidth, $newHeight];
553
+        return [ $newWidth, $newHeight ];
554 554
     }
555 555
 
556 556
     /**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
574 574
         }
575 575
 
576
-        return [$newWidth, $newHeight];
576
+        return [ $newWidth, $newHeight ];
577 577
     }
578 578
 
579 579
     /**
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
             } else {
603 603
                 $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
604 604
 
605
-                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) {
605
+                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) {
606 606
                     $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
607 607
                 }
608 608
             }
@@ -612,25 +612,25 @@  discard block
 block discarded – undo
612 612
             } else {
613 613
                 $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
614 614
 
615
-                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) {
615
+                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) {
616 616
                     $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
617 617
                 }
618 618
             }
619 619
         }
620 620
 
621
-        if ($newWidth < $newSizes[0]) {
622
-            $cropX = ($newSizes[0] - $newWidth) / 2;
621
+        if ($newWidth < $newSizes[ 0 ]) {
622
+            $cropX = ($newSizes[ 0 ] - $newWidth) / 2;
623 623
         } else {
624
-            $offsetX = ($newWidth - $newSizes[0]) / 2;
624
+            $offsetX = ($newWidth - $newSizes[ 0 ]) / 2;
625 625
         }
626 626
 
627
-        if ($newHeight < $newSizes[1]) {
628
-            $cropY = ($newSizes[1] - $newHeight) / 2;
627
+        if ($newHeight < $newSizes[ 1 ]) {
628
+            $cropY = ($newSizes[ 1 ] - $newHeight) / 2;
629 629
         } else {
630
-            $offsetY = ($newHeight - $newSizes[1]) / 2;
630
+            $offsetY = ($newHeight - $newSizes[ 1 ]) / 2;
631 631
         }
632 632
 
633
-        return [$newSizes[0], $newSizes[1], $offsetX, $offsetY, $cropX, $cropY];
633
+        return [ $newSizes[ 0 ], $newSizes[ 1 ], $offsetX, $offsetY, $cropX, $cropY ];
634 634
     }
635 635
 
636 636
     /**
@@ -677,6 +677,6 @@  discard block
 block discarded – undo
677 677
             }
678 678
         }
679 679
 
680
-        return [$newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY];
680
+        return [ $newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY ];
681 681
     }
682 682
 }
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
      * @link 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.