Completed
Push — master ( a36541...60d7b3 )
by Pavel
06:03 queued 03:57
created
src/SortAction.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
             Yii::$app->response->format = Response::FORMAT_JSON;
53 53
         }
54 54
         if (empty($this->modelClass) || !class_exists($this->modelClass)) {
55
-            throw new InvalidParamException('Define model class name for action ' . $this->controller->id . '::' . $this->id);
55
+            throw new InvalidParamException('Define model class name for action '.$this->controller->id.'::'.$this->id);
56 56
         }
57 57
         /** @var ActiveRecord $class */
58 58
         $class = $this->modelClass;
59 59
         /** @var SortableBehavior|ActiveRecord $model */
60 60
         $model = $class::findOne($id);
61 61
         if (!$model) {
62
-            throw new HttpException(404, 'Model `' . $this->modelClass . '` to change sort not found');
62
+            throw new HttpException(404, 'Model `'.$this->modelClass.'` to change sort not found');
63 63
         }
64 64
         switch ($position) {
65 65
             case 'top':
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             default:
74 74
                 if (strpos('ud-', $position[0]) !== false) {
75 75
                     // relative position
76
-                    $position = ($position[0] == 'u' ? '' : '-') . substr($position, 1);
76
+                    $position = ($position[0] == 'u' ? '' : '-').substr($position, 1);
77 77
                     if (is_numeric($position)) {
78 78
                         $model->sortChange($position);
79 79
                     }
Please login to merge, or discard this patch.
src/SortableBehavior.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $currentCondition = [];
78 78
         /** @var ActiveRecord $owner */
79 79
         $owner = $this->owner;
80
-        foreach ((array)$this->conditionAttributes as $attribute) {
80
+        foreach ((array) $this->conditionAttributes as $attribute) {
81 81
             if (!$owner->hasAttribute($attribute)) {
82 82
                 continue;
83 83
             }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         }
146 146
         $owner = $this->owner;
147 147
         $condition = $this->getCondition();
148
-        $newSort = $owner->{$this->sortAttribute} + $value;
148
+        $newSort = $owner->{$this->sortAttribute} +$value;
149 149
         if ($value > 0) {
150 150
             // move up
151 151
             $max = $this->getMaxSort();
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
             [$this->sortAttribute => new Expression('(@sortingCount:=(@sortingCount+1))')],
196 196
             $this->getCondition(),
197 197
             $params
198
-        ) . ' ' . $builder->buildOrderBy($orderFields);
199
-        $db->createCommand('set @sortingCount=-1;' . $query, $params)->execute();
198
+        ).' '.$builder->buildOrderBy($orderFields);
199
+        $db->createCommand('set @sortingCount=-1;'.$query, $params)->execute();
200 200
         // update in current record
201 201
         if (!$owner->getIsNewRecord()) {
202 202
             $owner->{$this->sortAttribute} = $owner->findOne($owner->getPrimaryKey())->{$this->sortAttribute};
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     protected function getCondition()
222 222
     {
223 223
         $condition = ['and'];
224
-        foreach ((array)$this->conditionAttributes as $attribute) {
224
+        foreach ((array) $this->conditionAttributes as $attribute) {
225 225
             if ($this->owner->hasAttribute($attribute)) {
226 226
                 $condition[] = [$attribute => $this->owner->$attribute];
227 227
             }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      */
237 237
     public function relativeMove($model, $position)
238 238
     {
239
-        $conditionAttributes = (array)$this->conditionAttributes;
239
+        $conditionAttributes = (array) $this->conditionAttributes;
240 240
         $owner = $this->owner;
241 241
 
242 242
         if (!empty($conditionAttributes)) {
Please login to merge, or discard this patch.