Completed
Push — master ( b56016...3d433d )
by Pavel
04:25
created
src/ImageBehavior.php 1 patch
Spacing   +11 added lines, -13 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     public function getImagePath()
120 120
     {
121 121
         if ($this->imagePath === null) {
122
-            $this->imagePath = '/images/' . strtolower((new \ReflectionClass($this->owner))->getShortName());
122
+            $this->imagePath = '/images/'.strtolower((new \ReflectionClass($this->owner))->getShortName());
123 123
         }
124 124
         return $this->imagePath;
125 125
     }
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
     public function getImageAbsolutePath()
142 142
     {
143 143
         if ($this->_imageAbsolutePath === null) {
144
-            $this->_imageAbsolutePath = Yii::getAlias('@webroot') .
145
-                '/' . (defined('IS_BACKEND') ? '../' : '') .
144
+            $this->_imageAbsolutePath = Yii::getAlias('@webroot').
145
+                '/'.(defined('IS_BACKEND') ? '../' : '').
146 146
                 ltrim($this->getImagePath(), '/');
147 147
             if (!file_exists($this->_imageAbsolutePath)) {
148 148
                 yii\helpers\FileHelper::createDirectory($this->_imageAbsolutePath);
@@ -178,8 +178,7 @@  discard block
 block discarded – undo
178 178
     public function getImageUrl()
179 179
     {
180 180
         return !$this->hasImage() ?
181
-            $this->getImageDefaultUrl() :
182
-            $this->_imageUrl($this->owner->getAttribute($this->imageAttribute));
181
+            $this->getImageDefaultUrl() : $this->_imageUrl($this->owner->getAttribute($this->imageAttribute));
183 182
     }
184 183
 
185 184
     /**
@@ -188,7 +187,7 @@  discard block
 block discarded – undo
188 187
      */
189 188
     public function getImageFile()
190 189
     {
191
-        return $this->getImageAbsolutePath() . '/' . $this->owner->getAttribute($this->imageAttribute);
190
+        return $this->getImageAbsolutePath().'/'.$this->owner->getAttribute($this->imageAttribute);
192 191
     }
193 192
 
194 193
     /**
@@ -221,10 +220,10 @@  discard block
 block discarded – undo
221 220
         if (!file_exists($sourceFile)) {
222 221
             return false;
223 222
         }
224
-        $imageName = $this->imageAttribute . '_' .
225
-            md5(implode('-', (array)$this->owner->getPrimaryKey()) . microtime(true) . rand()) .
226
-            '.' . pathinfo($fileName)['extension'];
227
-        $destinationFile = $this->getImageAbsolutePath() . '/' . $imageName;
223
+        $imageName = $this->imageAttribute.'_'.
224
+            md5(implode('-', (array) $this->owner->getPrimaryKey()).microtime(true).rand()).
225
+            '.'.pathinfo($fileName)['extension'];
226
+        $destinationFile = $this->getImageAbsolutePath().'/'.$imageName;
228 227
         if (!copy($sourceFile, $destinationFile)) {
229 228
             return false;
230 229
         }
@@ -254,8 +253,7 @@  discard block
 block discarded – undo
254 253
                         yii\imagine\Image::getImagine(),
255 254
                         $newBox,
256 255
                         $size[0] == $currentBox->getWidth() ?
257
-                            new Point(0, ($size[1] - $currentBox->getHeight()) / 2) :
258
-                            new Point(($size[0] - $currentBox->getWidth()) / 2, 0),
256
+                            new Point(0, ($size[1] - $currentBox->getHeight()) / 2) : new Point(($size[0] - $currentBox->getWidth()) / 2, 0),
259 257
                         new Color($frameColor, $alpha)
260 258
                     )
261 259
                 )->apply($image);
@@ -297,7 +295,7 @@  discard block
 block discarded – undo
297 295
      */
298 296
     protected function _imageUrl($imageFileName)
299 297
     {
300
-        return $this->getImagePath() . '/' . $imageFileName;
298
+        return $this->getImagePath().'/'.$imageFileName;
301 299
     }
302 300
 
303 301
 }
Please login to merge, or discard this patch.
src/ImageAsset.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 use yii\web\AssetBundle;
13 13
 
14
-class ImageAsset extends AssetBundle{
14
+class ImageAsset extends AssetBundle {
15 15
     public $sourcePath = '@inblank/image/assets';
16 16
     public $css = [
17 17
         'styles.css',
Please login to merge, or discard this patch.
src/ImageUploadWidget.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,22 +39,22 @@
 block discarded – undo
39 39
         if (!isset($form->options['enctype'])) {
40 40
             $form->options['enctype'] = 'multipart/form-data';
41 41
         }
42
-        $str = '<div class="upload-image-preview" style="background-image: url(' . $this->model->imageUrl . ')"></div>' .
42
+        $str = '<div class="upload-image-preview" style="background-image: url('.$this->model->imageUrl.')"></div>'.
43 43
 
44
-            '<div class="upload-image-control">' .
44
+            '<div class="upload-image-control">'.
45 45
 
46
-            '<a class="btn btn-primary upload-image-change" title="' . $this->messages['change'] . '">' .
47
-            Html::activeFileInput($this->model, $this->attribute, $this->options) .
48
-            '<span class="glyphicon glyphicon-save"></span>' .
49
-            '</a>' .
46
+            '<a class="btn btn-primary upload-image-change" title="'.$this->messages['change'].'">'.
47
+            Html::activeFileInput($this->model, $this->attribute, $this->options).
48
+            '<span class="glyphicon glyphicon-save"></span>'.
49
+            '</a>'.
50 50
 
51
-            '<a class="btn btn-danger upload-image-clear" title="' . $this->messages['clear'] . '">' .
52
-            '<span class="glyphicon glyphicon-trash"></span>' .
53
-            '</a>' .
51
+            '<a class="btn btn-danger upload-image-clear" title="'.$this->messages['clear'].'">'.
52
+            '<span class="glyphicon glyphicon-trash"></span>'.
53
+            '</a>'.
54 54
 
55
-            '<a class="btn btn-success upload-image-reset" title="' . $this->messages['reset'] . '">' .
56
-            '<span class="glyphicon glyphicon-repeat"></span>' .
57
-            '</a>' .
55
+            '<a class="btn btn-success upload-image-reset" title="'.$this->messages['reset'].'">'.
56
+            '<span class="glyphicon glyphicon-repeat"></span>'.
57
+            '</a>'.
58 58
 
59 59
             '</div>';
60 60
 
Please login to merge, or discard this patch.