Passed
Push — master ( e24b23...32beb9 )
by kicaj
03:56
created
src/Model/Behavior/FileBehavior.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
             'webp',
39 39
         ],
40 40
         'path' => 'files',
41
-        'background' => [255, 255, 255, 127],
41
+        'background' => [ 255, 255, 255, 127 ],
42 42
         'watermark' => '',
43
-        'thumbs' => [],
43
+        'thumbs' => [ ],
44 44
     ];
45 45
 
46 46
     /**
@@ -48,22 +48,22 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var array
50 50
      */
51
-    protected $_files = [];
51
+    protected $_files = [ ];
52 52
 
53 53
     /**
54 54
      * {@inheritDoc}
55 55
      */
56 56
     public function initialize(array $config)
57 57
     {
58
-        $this->_config = [];
58
+        $this->_config = [ ];
59 59
 
60 60
         foreach ($config as $field => $fieldOptions) {
61 61
             if (is_array($fieldOptions)) {
62
-                $this->_config[$this->getTable()->getAlias()][$field] = array_merge($this->_defaultConfig, $fieldOptions);
62
+                $this->_config[ $this->getTable()->getAlias() ][ $field ] = array_merge($this->_defaultConfig, $fieldOptions);
63 63
             } else {
64 64
                 $field = $fieldOptions;
65 65
 
66
-                $this->_config[$this->getTable()->getAlias()][$field] = $this->_defaultConfig;
66
+                $this->_config[ $this->getTable()->getAlias() ][ $field ] = $this->_defaultConfig;
67 67
             }
68 68
         }
69 69
     }
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
     /**
72 72
      * {@inheritDoc}
73 73
      */
74
-    public function beforeMarshal(Event $event, $data = [], $options = [])
74
+    public function beforeMarshal(Event $event, $data = [ ], $options = [ ])
75 75
     {
76 76
         if (!empty($config = $this->getConfig($this->getTable()->getAlias()))) {
77 77
             foreach ($config as $field => $fieldOptions) {
78 78
                 if (array_key_exists($field, $data)) {
79 79
                     // Save file array to suffixed field
80
-                    $data['_' . $field] = $data[$field];
80
+                    $data[ '_'.$field ] = $data[ $field ];
81 81
 
82 82
                     // Detect multiple files by array keys
83
-                    if (is_numeric(key($data[$field]))) {
84
-                        foreach (array_keys($data[$field]) as $key) {
85
-                            if (!empty($data[$field][$key]['tmp_name'])) {
86
-                                $this->_files[$field . '_' . $key] = array_merge($fieldOptions, [
87
-                                    'name' => $this->_prepareName($data[$field][$key]['name']),
88
-                                    'source' => $data[$field][$key]['tmp_name'],
83
+                    if (is_numeric(key($data[ $field ]))) {
84
+                        foreach (array_keys($data[ $field ]) as $key) {
85
+                            if (!empty($data[ $field ][ $key ][ 'tmp_name' ])) {
86
+                                $this->_files[ $field.'_'.$key ] = array_merge($fieldOptions, [
87
+                                    'name' => $this->_prepareName($data[ $field ][ $key ][ 'name' ]),
88
+                                    'source' => $data[ $field ][ $key ][ 'tmp_name' ],
89 89
                                 ]);
90 90
 
91
-                                $data[$field][$key] = $this->_files[$field . '_' . $key]['name'];
91
+                                $data[ $field ][ $key ] = $this->_files[ $field.'_'.$key ][ 'name' ];
92 92
                             } else {
93
-                                unset($data[$field][$key]);
93
+                                unset($data[ $field ][ $key ]);
94 94
                             }
95 95
                         }
96 96
                     } else {
97
-                        if (!empty($data[$field]['tmp_name'])) {
98
-                            $this->_files[$field] = array_merge($fieldOptions, [
99
-                                'name' => $this->_prepareName($data[$field]['name']),
100
-                                'source' => $data[$field]['tmp_name'],
97
+                        if (!empty($data[ $field ][ 'tmp_name' ])) {
98
+                            $this->_files[ $field ] = array_merge($fieldOptions, [
99
+                                'name' => $this->_prepareName($data[ $field ][ 'name' ]),
100
+                                'source' => $data[ $field ][ 'tmp_name' ],
101 101
                             ]);
102 102
 
103
-                            $data[$field] = $this->_files[$field]['name'];
103
+                            $data[ $field ] = $this->_files[ $field ][ 'name' ];
104 104
                         } else {
105
-                            unset($data[$field]);
105
+                            unset($data[ $field ]);
106 106
                         }
107 107
                     }
108 108
                 }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
     /**
114 114
      * {@inheritDoc}
115 115
      */
116
-    public function afterSave(Event $event, EntityInterface $entity, $options = [])
116
+    public function afterSave(Event $event, EntityInterface $entity, $options = [ ])
117 117
     {
118 118
         $this->_prepareFile($entity);
119 119
     }
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
     protected function _prepareFile(EntityInterface $entity)
135 135
     {
136 136
         foreach ($this->_files as $field => $fieldOptions) {
137
-            if (!is_dir($fieldOptions['path'])) {
138
-                $this->_prepareDir($fieldOptions['path']);
137
+            if (!is_dir($fieldOptions[ 'path' ])) {
138
+                $this->_prepareDir($fieldOptions[ 'path' ]);
139 139
             }
140 140
 
141
-            $file = $fieldOptions['path'] . DS . $fieldOptions['name'];
141
+            $file = $fieldOptions[ 'path' ].DS.$fieldOptions[ 'name' ];
142 142
 
143
-            if (move_uploaded_file($fieldOptions['source'], $file) || (file_exists($fieldOptions['source']) && rename($fieldOptions['source'], $file))) {
144
-                $fileType = mb_strtolower(getimagesize($fieldOptions['source'])['mime']);
143
+            if (move_uploaded_file($fieldOptions[ 'source' ], $file) || (file_exists($fieldOptions[ 'source' ]) && rename($fieldOptions[ 'source' ], $file))) {
144
+                $fileType = mb_strtolower(getimagesize($fieldOptions[ 'source' ])[ 'mime' ]);
145 145
 
146
-                $fieldTypes = array_map(function ($fieldType) {
146
+                $fieldTypes = array_map(function($fieldType) {
147 147
                     return mb_strtolower($fieldType);
148
-                }, $fieldOptions['types']);
148
+                }, $fieldOptions[ 'types' ]);
149 149
 
150 150
                 // Create thumbs
151 151
                 if (mb_strpos($fileType, 'image/') !== false && in_array($fileType, $fieldTypes)) {
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
         // Get field list of model schema
167 167
         $modelSchema = $model->schema();
168 168
 
169
-        foreach ($this->settings[$model->alias] as $fieldName => $fieldOptions) {
169
+        foreach ($this->settings[ $model->alias ] as $fieldName => $fieldOptions) {
170 170
             // Check is field in model schema
171
-            if (isset($modelSchema[$fieldName])) {
171
+            if (isset($modelSchema[ $fieldName ])) {
172 172
                 $dataField = $model->findById($model->id);
173 173
 
174
-                if (is_array($dataField) && !empty($dataField[$model->alias][$fieldName])) {
174
+                if (is_array($dataField) && !empty($dataField[ $model->alias ][ $fieldName ])) {
175 175
                     // Pattern for original file with thumbs
176
-                    $filePattern = $this->settings[$model->alias][$fieldName]['path'] . DS . substr($dataField[$model->alias][$fieldName], 0, 14);
176
+                    $filePattern = $this->settings[ $model->alias ][ $fieldName ][ 'path' ].DS.substr($dataField[ $model->alias ][ $fieldName ], 0, 14);
177 177
 
178
-                    foreach (glob($filePattern . '*') as $fileName) {
178
+                    foreach (glob($filePattern.'*') as $fileName) {
179 179
                         // Remove file
180 180
                         @unlink($fileName);
181 181
                     }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
     {
198 198
         if (is_file($originalFile) && is_array($settingParams)) {
199 199
             // Check image library
200
-            if (!extension_loaded($settingParams['library'])) {
201
-                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams['library']));
200
+            if (!extension_loaded($settingParams[ 'library' ])) {
201
+                throw new LibraryException(__d('file', 'The library identified by {0} is not loaded!', $settingParams[ 'library' ]));
202 202
             }
203 203
 
204 204
             // Get extension from original file
205 205
             $fileExtension = $this->getExtension($originalFile);
206 206
 
207
-            switch ($settingParams['library']) {
207
+            switch ($settingParams[ 'library' ]) {
208 208
                 // Get image resource
209 209
                 case 'gd':
210 210
                     switch ($fileExtension) {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
                     break;
248 248
                 default:
249
-                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams['library']));
249
+                    throw new LibraryException(__d('file', 'The library identified by {0} it is not known as image processing!', $settingParams[ 'library' ]));
250 250
             }
251 251
 
252 252
             $offsetX = 0;
@@ -255,48 +255,48 @@  discard block
 block discarded – undo
255 255
             $cropX = 0;
256 256
             $cropY = 0;
257 257
 
258
-            foreach ($settingParams['thumbs'] as $thumbName => $thumbParam) {
258
+            foreach ($settingParams[ 'thumbs' ] as $thumbName => $thumbParam) {
259 259
                 if (is_array($thumbParam)) {
260
-                    if (isset($thumbParam['width']) && is_array($thumbParam['width']) && count($thumbParam['width']) === 1) {
261
-                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam['width'][0]);
262
-                    } elseif (isset($thumbParam['height']) && is_array($thumbParam['height']) && count($thumbParam['height']) === 1) {
263
-                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam['height'][0]);
264
-                    } elseif (isset($thumbParam['shorter']) && is_array($thumbParam['shorter']) && count($thumbParam['shorter']) === 2) {
265
-                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam['shorter'][0], $thumbParam['shorter'][1]);
266
-                    } elseif (isset($thumbParam['longer']) && is_array($thumbParam['longer']) && count($thumbParam['longer']) === 2) {
267
-                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam['longer'][0], $thumbParam['longer'][1]);
268
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 2) {
269
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1]);
270
-                    } elseif (isset($thumbParam['fit']) && is_array($thumbParam['fit']) && count($thumbParam['fit']) === 3) {
271
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam['fit'][0], $thumbParam['fit'][1], $thumbParam['fit'][2]);
272
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 1) {
273
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0]);
274
-                    } elseif (isset($thumbParam['square']) && is_array($thumbParam['square']) && count($thumbParam['square']) === 2) {
275
-                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam['square'][0], $thumbParam['square'][1]);
260
+                    if (isset($thumbParam[ 'width' ]) && is_array($thumbParam[ 'width' ]) && count($thumbParam[ 'width' ]) === 1) {
261
+                        list($newWidth, $newHeight) = $this->_byWidth($originalWidth, $originalHeight, $thumbParam[ 'width' ][ 0 ]);
262
+                    } elseif (isset($thumbParam[ 'height' ]) && is_array($thumbParam[ 'height' ]) && count($thumbParam[ 'height' ]) === 1) {
263
+                        list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $thumbParam[ 'height' ][ 0 ]);
264
+                    } elseif (isset($thumbParam[ 'shorter' ]) && is_array($thumbParam[ 'shorter' ]) && count($thumbParam[ 'shorter' ]) === 2) {
265
+                        list($newWidth, $newHeight) = $this->_byShorter($originalWidth, $originalHeight, $thumbParam[ 'shorter' ][ 0 ], $thumbParam[ 'shorter' ][ 1 ]);
266
+                    } elseif (isset($thumbParam[ 'longer' ]) && is_array($thumbParam[ 'longer' ]) && count($thumbParam[ 'longer' ]) === 2) {
267
+                        list($newWidth, $newHeight) = $this->_byLonger($originalWidth, $originalHeight, $thumbParam[ 'longer' ][ 0 ], $thumbParam[ 'longer' ][ 1 ]);
268
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 2) {
269
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ]);
270
+                    } elseif (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]) && count($thumbParam[ 'fit' ]) === 3) {
271
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_byFit($originalWidth, $originalHeight, $thumbParam[ 'fit' ][ 0 ], $thumbParam[ 'fit' ][ 1 ], $thumbParam[ 'fit' ][ 2 ]);
272
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 1) {
273
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ]);
274
+                    } elseif (isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ]) && count($thumbParam[ 'square' ]) === 2) {
275
+                        list($newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY) = $this->_bySquare($originalWidth, $originalHeight, $thumbParam[ 'square' ][ 0 ], $thumbParam[ 'square' ][ 1 ]);
276 276
                     } else {
277 277
                         throw new ThumbsException(__d('file', 'Unknown type of creating thumbnails!'));
278 278
                     }
279 279
 
280 280
                     $thumbFile = str_replace('default', $thumbName, $originalFile);
281 281
 
282
-                    switch ($settingParams['library']) {
282
+                    switch ($settingParams[ 'library' ]) {
283 283
                         // Get image resource
284 284
                         case 'gd':
285 285
                             $newImage = imagecreatetruecolor($newWidth, $newHeight);
286 286
 
287
-                            if (is_array($settingParams['background'])) {
287
+                            if (is_array($settingParams[ 'background' ])) {
288 288
                                 // Set background color and transparent indicates
289
-                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
289
+                                imagefill($newImage, 0, 0, imagecolorallocatealpha($newImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
290 290
                             }
291 291
 
292 292
                             imagecopyresampled($newImage, $sourceImage, 0, 0, 0, 0, $newWidth, $newHeight, $originalWidth, $originalHeight);
293 293
 
294
-                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) {
294
+                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) {
295 295
                                 $fitImage = imagecreatetruecolor($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY));
296 296
 
297
-                                if (is_array($settingParams['background'])) {
297
+                                if (is_array($settingParams[ 'background' ])) {
298 298
                                     // Set background color and transparent indicates
299
-                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams['background'][0], $settingParams['background'][1], $settingParams['background'][2], $settingParams['background'][3]));
299
+                                    imagefill($fitImage, 0, 0, imagecolorallocatealpha($fitImage, $settingParams[ 'background' ][ 0 ], $settingParams[ 'background' ][ 1 ], $settingParams[ 'background' ][ 2 ], $settingParams[ 'background' ][ 3 ]));
300 300
                                 }
301 301
 
302 302
                                 imagecopyresampled($fitImage, $newImage, $offsetX, $offsetY, $cropX, $cropY, $newWidth, $newHeight, $newWidth, $newHeight);
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
                             imagesavealpha($newImage, true);
309 309
 
310 310
                             // Watermark
311
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
311
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
312 312
                                 $watermarkImage = imagecreatefromstring($watermarkSource);
313 313
 
314
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam['watermark']);
314
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition(imagesx($newImage), imagesy($newImage), imagesx($watermarkImage), imagesy($watermarkImage), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
315 315
 
316 316
                                 // Set transparent
317 317
                                 imagealphablending($newImage, true);
@@ -350,16 +350,16 @@  discard block
 block discarded – undo
350 350
                             $newImage->setimagebackgroundcolor('transparent');
351 351
                             $newImage->extentimage($newWidth + (2 * $offsetX), $newHeight + (2 * $offsetY), -$offsetX, -$offsetY);
352 352
 
353
-                            if ((isset($thumbParam['square']) && is_array($thumbParam['square'])) || (isset($thumbParam['fit']) && is_array($thumbParam['fit']))) {
353
+                            if ((isset($thumbParam[ 'square' ]) && is_array($thumbParam[ 'square' ])) || (isset($thumbParam[ 'fit' ]) && is_array($thumbParam[ 'fit' ]))) {
354 354
                                 $newImage->cropimage($newWidth + (2 * $offsetX) - (2 * $cropX), $newHeight + (2 * $offsetY) - (2 * $cropY), $cropX, $cropY);
355 355
                             }
356 356
 
357 357
                             // Watermark
358
-                            if (isset($thumbParam['watermark']) && ($watermarkSource = file_get_contents($settingParams['watermark'])) !== false) {
358
+                            if (isset($thumbParam[ 'watermark' ]) && ($watermarkSource = file_get_contents($settingParams[ 'watermark' ])) !== false) {
359 359
                                 $watermarkImage = new \Imagick();
360 360
                                 $watermarkImage->readimageblob($watermarkSource);
361 361
 
362
-                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam['watermark']);
362
+                                list($watermarkPositionX, $watermarkPositionY) = $this->getPosition($newWidth, $newHeight, $watermarkImage->getimagewidth(), $watermarkImage->getimageheight(), $offsetX, $offsetY, $thumbParam[ 'watermark' ]);
363 363
 
364 364
                                 $newImage->compositeimage($watermarkImage, \Imagick::COMPOSITE_OVER, $watermarkPositionX, $watermarkPositionY);
365 365
                             }
@@ -419,43 +419,43 @@  discard block
 block discarded – undo
419 419
     {
420 420
         switch (intval($positionValue)) {
421 421
             case 1: // Top left
422
-                return [$offsetX, $offsetY];
422
+                return [ $offsetX, $offsetY ];
423 423
 
424 424
                 break;
425 425
             case 2: // Top center
426
-                return [($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY];
426
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), 0 + $offsetY ];
427 427
 
428 428
                 break;
429 429
             case 3: // Top right
430
-                return [($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY];
430
+                return [ ($newWidth - $watermarkWidth) - $offsetX, 0 + $offsetY ];
431 431
 
432 432
                 break;
433 433
             case 4: // Middle left
434
-                return [$offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
434
+                return [ $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
435 435
 
436 436
                 break;
437 437
             case 5: // Middle center
438
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2)];
438
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight / 2) - ($watermarkHeight / 2) ];
439 439
 
440 440
                 break;
441 441
             case 6: // Middle right
442
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2)];
442
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight / 2) - ($watermarkHeight / 2) ];
443 443
 
444 444
                 break;
445 445
             case 7: // Bottom left
446
-                return [$offsetX, ($newHeight - $watermarkHeight) - $offsetY];
446
+                return [ $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
447 447
 
448 448
                 break;
449 449
             case 8: // Bottom center
450
-                return [($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY];
450
+                return [ ($newWidth / 2) - ($watermarkWidth / 2), ($newHeight - $watermarkHeight) - $offsetY ];
451 451
 
452 452
                 break;
453 453
             case 9: // Bottom right
454
-                return [($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY];
454
+                return [ ($newWidth - $watermarkWidth) - $offsetX, ($newHeight - $watermarkHeight) - $offsetY ];
455 455
 
456 456
                 break;
457 457
             default:
458
-                return [$offsetX, $offsetY];
458
+                return [ $offsetX, $offsetY ];
459 459
 
460 460
                 break;
461 461
         }
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
      */
473 473
     protected function _prepareName($fieldName)
474 474
     {
475
-        return Text::uuid() . '_default.' . $this->getExtension($fieldName);
475
+        return Text::uuid().'_default.'.$this->getExtension($fieldName);
476 476
     }
477 477
 
478 478
     /**
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
      */
485 485
     protected function _prepareDir($dirPath)
486 486
     {
487
-        $dirPath = WWW_ROOT . str_replace('/', DS, $dirPath);
487
+        $dirPath = WWW_ROOT.str_replace('/', DS, $dirPath);
488 488
 
489 489
         if (!is_dir($dirPath) && mb_strlen($dirPath) > 0) {
490 490
             mkdir($dirPath, 0777, true);
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             $newHeight = intval($newWidth * ($originalHeight / $originalWidth));
515 515
         }
516 516
 
517
-        return [$newWidth, $newHeight];
517
+        return [ $newWidth, $newHeight ];
518 518
     }
519 519
 
520 520
     /**
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
             $newWidth = intval($newHeight * ($originalWidth / $originalHeight));
537 537
         }
538 538
 
539
-        return [$newWidth, $newHeight];
539
+        return [ $newWidth, $newHeight ];
540 540
     }
541 541
 
542 542
     /**
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
560 560
         }
561 561
 
562
-        return [$newWidth, $newHeight];
562
+        return [ $newWidth, $newHeight ];
563 563
     }
564 564
 
565 565
     /**
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
             list($newWidth, $newHeight) = $this->_byHeight($originalWidth, $originalHeight, $newHeight);
583 583
         }
584 584
 
585
-        return [$newWidth, $newHeight];
585
+        return [ $newWidth, $newHeight ];
586 586
     }
587 587
 
588 588
     /**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
             } else {
612 612
                 $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
613 613
 
614
-                if ($newWidth < $newSizes[0] || $newHeight < $newSizes[1]) {
614
+                if ($newWidth < $newSizes[ 0 ] || $newHeight < $newSizes[ 1 ]) {
615 615
                     $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
616 616
                 }
617 617
             }
@@ -621,25 +621,25 @@  discard block
 block discarded – undo
621 621
             } else {
622 622
                 $newSizes = $this->_byShorter($originalWidth, $originalHeight, $newWidth, $newHeight);
623 623
 
624
-                if ($newWidth > $newSizes[0] || $newHeight > $newSizes[1]) {
624
+                if ($newWidth > $newSizes[ 0 ] || $newHeight > $newSizes[ 1 ]) {
625 625
                     $newSizes = $this->_byLonger($originalWidth, $originalHeight, $newWidth, $newHeight);
626 626
                 }
627 627
             }
628 628
         }
629 629
 
630
-        if ($newWidth < $newSizes[0]) {
631
-            $cropX = ($newSizes[0] - $newWidth) / 2;
630
+        if ($newWidth < $newSizes[ 0 ]) {
631
+            $cropX = ($newSizes[ 0 ] - $newWidth) / 2;
632 632
         } else {
633
-            $offsetX = ($newWidth - $newSizes[0]) / 2;
633
+            $offsetX = ($newWidth - $newSizes[ 0 ]) / 2;
634 634
         }
635 635
 
636
-        if ($newHeight < $newSizes[1]) {
637
-            $cropY = ($newSizes[1] - $newHeight) / 2;
636
+        if ($newHeight < $newSizes[ 1 ]) {
637
+            $cropY = ($newSizes[ 1 ] - $newHeight) / 2;
638 638
         } else {
639
-            $offsetY = ($newHeight - $newSizes[1]) / 2;
639
+            $offsetY = ($newHeight - $newSizes[ 1 ]) / 2;
640 640
         }
641 641
 
642
-        return [$newSizes[0], $newSizes[1], $offsetX, $offsetY, $cropX, $cropY];
642
+        return [ $newSizes[ 0 ], $newSizes[ 1 ], $offsetX, $offsetY, $cropX, $cropY ];
643 643
     }
644 644
 
645 645
     /**
@@ -686,6 +686,6 @@  discard block
 block discarded – undo
686 686
             }
687 687
         }
688 688
 
689
-        return [$newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY];
689
+        return [ $newWidth, $newHeight, $offsetX, $offsetY, $cropX, $cropY ];
690 690
     }
691 691
 }
692 692
\ No newline at end of file
Please login to merge, or discard this patch.