Passed
Push — master ( a2d4f7...a7c195 )
by Evgenii
02:53 queued 12s
created
src/models/File.php 1 patch
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -87,29 +87,37 @@  discard block
 block discarded – undo
87 87
     {
88 88
         $icon = IconHelper::FILE;
89 89
 
90
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')
91
-            $icon = IconHelper::FILE_WORD;
90
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') {
91
+                    $icon = IconHelper::FILE_WORD;
92
+        }
92 93
 
93
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
94
-            $icon = IconHelper::FILE_EXCEL;
94
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
95
+                    $icon = IconHelper::FILE_EXCEL;
96
+        }
95 97
 
96
-        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation')
97
-            $icon = IconHelper::FILE_POWERPOINT;
98
+        if ($this->content_type == 'application/vnd.openxmlformats-officedocument.presentationml.presentation') {
99
+                    $icon = IconHelper::FILE_POWERPOINT;
100
+        }
98 101
 
99
-        if ($this->content_type == 'application/x-zip-compressed')
100
-            $icon = IconHelper::FILE_ARCHIVE;
102
+        if ($this->content_type == 'application/x-zip-compressed') {
103
+                    $icon = IconHelper::FILE_ARCHIVE;
104
+        }
101 105
 
102
-        if ($this->content_type == 'application/octet-stream')
103
-            $icon = IconHelper::FILE_ARCHIVE;
106
+        if ($this->content_type == 'application/octet-stream') {
107
+                    $icon = IconHelper::FILE_ARCHIVE;
108
+        }
104 109
 
105
-        if (preg_match('/audio/', $this->content_type))
106
-            $icon = IconHelper::FILE_AUDIO;
110
+        if (preg_match('/audio/', $this->content_type)) {
111
+                    $icon = IconHelper::FILE_AUDIO;
112
+        }
107 113
 
108
-        if (preg_match('/pdf/', $this->content_type))
109
-            $icon = IconHelper::FILE_PDF;
114
+        if (preg_match('/pdf/', $this->content_type)) {
115
+                    $icon = IconHelper::FILE_PDF;
116
+        }
110 117
 
111
-        if ($this->type == FileType::VIDEO)
112
-            $icon = IconHelper::FILE_VIDEO;
118
+        if ($this->type == FileType::VIDEO) {
119
+                    $icon = IconHelper::FILE_VIDEO;
120
+        }
113 121
 
114 122
         return $icon;
115 123
     }
@@ -225,8 +233,9 @@  discard block
 block discarded – undo
225 233
 
226 234
     public function getRootPreviewPath()
227 235
     {
228
-        if ($this->isSvg())
229
-            return $this->getRootPath();
236
+        if ($this->isSvg()) {
237
+                    return $this->getRootPath();
238
+        }
230 239
 
231 240
         return Yii::$app->getModule('files')->storageFullPath . $this->filename . '.jpg';
232 241
     }
@@ -257,8 +266,9 @@  discard block
 block discarded – undo
257 266
 
258 267
     public function getHref()
259 268
     {
260
-        if ($this->isImage() && Yii::$app->getModule('files')->hostStatic)
261
-            return Yii::$app->getModule('files')->hostStatic . $this->filename . "?hash={$this->hash}";
269
+        if ($this->isImage() && Yii::$app->getModule('files')->hostStatic) {
270
+                    return Yii::$app->getModule('files')->hostStatic . $this->filename . "?hash={$this->hash}";
271
+        }
262 272
         return Url::to(['/files/default/get', 'hash' => $this->hash]);
263 273
     }
264 274
 
@@ -342,8 +352,9 @@  discard block
 block discarded – undo
342 352
             isset($this->behaviors['files']) &&
343 353
             isset($this->behaviors['files']->attributes[$this->field]) &&
344 354
             isset($this->behaviors['files']->attributes[$this->field]['watermark'])
345
-        )
346
-            return $this->behaviors['files']->attributes[$this->field]['watermark'];
355
+        ) {
356
+                    return $this->behaviors['files']->attributes[$this->field]['watermark'];
357
+        }
347 358
     }
348 359
 
349 360
     /**
@@ -363,17 +374,20 @@  discard block
 block discarded – undo
363 374
      */
364 375
     public function getPreviewWebPath(int $width = 0, bool $webp = false)
365 376
     {
366
-        if (!file_exists($this->getRootPath()))
367
-            return null;
377
+        if (!file_exists($this->getRootPath())) {
378
+                    return null;
379
+        }
368 380
 
369
-        if (!$this->isVideo() && !$this->isImage())
370
-            throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
381
+        if (!$this->isVideo() && !$this->isImage()) {
382
+                    throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
383
+        }
371 384
 
372
-        if (Yii::$app->getModule('files')->hostStatic)
373
-            return
385
+        if (Yii::$app->getModule('files')->hostStatic) {
386
+                    return
374 387
                 Yii::$app->getModule('files')->hostStatic .
375 388
                 $this->makeNameWithSize($this->filename, $width, $webp) .
376 389
                 "?hash={$this->hash}&width={$width}&webp=" . intval($webp);
390
+        }
377 391
 
378 392
         return Url::toRoute(['/files/default/image', 'hash' => $this->hash, 'width' => $width, 'webp' => $webp]);
379 393
     }
@@ -409,8 +423,9 @@  discard block
 block discarded – undo
409 423
      */
410 424
     public function getPreviewRootPath($width = 0, $webp = false)
411 425
     {
412
-        if (!$this->isVideo() && !$this->isImage())
413
-            throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
426
+        if (!$this->isVideo() && !$this->isImage()) {
427
+                    throw new ErrorException('Requiested file is not an image and its implsible to resize it.');
428
+        }
414 429
         return $this->makeNameWithSize($this->rootPath, $width, $webp);
415 430
     }
416 431
 
Please login to merge, or discard this patch.