Completed
Push — master ( 0efc49...50a99d )
by Evgenii
03:46
created
src/logic/FileResize.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,11 +33,13 @@  discard block
 block discarded – undo
33 33
     {
34 34
         $this->_file = $file;
35 35
 
36
-        if ($this->_file->type != FileType::IMAGE)
37
-            throw new ErrorException('This file is not an image.');
36
+        if ($this->_file->type != FileType::IMAGE) {
37
+                    throw new ErrorException('This file is not an image.');
38
+        }
38 39
 
39
-        if (!file_exists($this->_file->rootPath))
40
-            throw new ErrorException('File not found on disk');
40
+        if (!file_exists($this->_file->rootPath)) {
41
+                    throw new ErrorException('File not found on disk');
42
+        }
41 43
 
42 44
         $this->_maxHeight = $maxHeight;
43 45
         $this->_maxWidth = $maxWidth;
@@ -51,16 +53,18 @@  discard block
 block discarded – undo
51 53
      */
52 54
     public function execute(): bool
53 55
     {
54
-        if ($this->_file->content_type == 'image/svg+xml')
55
-            return true;
56
+        if ($this->_file->content_type == 'image/svg+xml') {
57
+                    return true;
58
+        }
56 59
 
57 60
         $image = new SimpleImage();
58 61
         $image->load($this->_file->rootPath);
59 62
 
60 63
         if ($image->getWidth() > $this->_maxWidth || $image->getHeight() > $this->_maxHeight) {
61 64
             $image->resizeToWidth($this->_maxWidth);
62
-            if ($this->_file->content_type == 'image/png')
63
-                $this->_imageType = IMAGETYPE_PNG;
65
+            if ($this->_file->content_type == 'image/png') {
66
+                            $this->_imageType = IMAGETYPE_PNG;
67
+            }
64 68
             $image->save($this->_file->rootPath, $this->_imageType, $this->_compression);
65 69
             $this->_file->size = filesize($this->_file->rootPath);
66 70
             return $this->_file->save(false, ['size']);
Please login to merge, or discard this patch.