Completed
Push — master ( 5d0f9f...7d804c )
by Maksim
12:58
created
src/Exceptions/NotSupportedMultiUnitFieldUnit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,6 +8,6 @@
 block discarded – undo
8 8
 {
9 9
     public function __construct($field, $unit, $code = 0, Throwable $previous = null)
10 10
     {
11
-        parent::__construct('Requested field "'.$field.'" doesn\'t support ' . $unit, $code, $previous);
11
+        parent::__construct('Requested field "' . $field . '" doesn\'t support ' . $unit, $code, $previous);
12 12
     }
13 13
 }
Please login to merge, or discard this patch.
src/Traits/MultiUnitSupport.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
     private function getUnitConversionDataColumns()
19 19
     {
20 20
         return array_map(function ($column) {
21
-            return $column.$this->getUnitConversionDataPostfix();
21
+            return $column . $this->getUnitConversionDataPostfix();
22 22
         }, array_keys($this->getMultiUnitColumns()));
23 23
     }
24 24
 
25 25
     private function getUnitConversionUnitColumns()
26 26
     {
27 27
         return array_map(function ($column) {
28
-            return $column.$this->getUnitAttributePostfix();
28
+            return $column . $this->getUnitAttributePostfix();
29 29
         }, array_keys($this->getMultiUnitColumns()));
30 30
     }
31 31
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
              */
67 67
             foreach ($model->getMultiUnitColumns() as $unitBasedColumn => $options) {
68 68
                 if (isset($model->attributes[$unitBasedColumn])) {
69
-                    $model->{$unitBasedColumn.$model->getUnitConversionDataPostfix()} = json_encode(
69
+                    $model->{$unitBasedColumn . $model->getUnitConversionDataPostfix()} = json_encode(
70 70
                         $model->calculateMultiUnitConversionData(
71 71
                             $model->attributes[$unitBasedColumn],
72 72
                             $model->getMultiUnitFieldUnit($unitBasedColumn),
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
              * @var Model|MultiUnitSupport $model
92 92
              */
93 93
             foreach (Arr::only($model->getMultiUnitColumns(), array_keys($model->getDirty())) as $unitBasedColumn => $options) {
94
-                $model->{$unitBasedColumn.$model->getUnitConversionDataPostfix()} = json_encode($model->calculateMultiUnitConversionData($model->getDirty()[$unitBasedColumn], new $options['default_unit'](), $options['supported_units']));
94
+                $model->{$unitBasedColumn . $model->getUnitConversionDataPostfix()} = json_encode($model->calculateMultiUnitConversionData($model->getDirty()[$unitBasedColumn], new $options['default_unit'](), $options['supported_units']));
95 95
             }
96 96
         });
97 97
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
     public function getMultiUnitExistingConversionData($field)
121 121
     {
122
-        return json_decode($this->{$field.$this->getUnitConversionDataPostfix()} ?? null);
122
+        return json_decode($this->{$field . $this->getUnitConversionDataPostfix()} ?? null);
123 123
     }
124 124
 
125 125
     /**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                     break;
220 220
                 }
221 221
             }
222
-            if($found)
222
+            if ($found)
223 223
                 $this->multiUnitSelectedUnits[$field] = $unitClass;
224 224
             else
225 225
                 throw new NotSupportedMultiUnitFieldUnit($field, $unit);
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
      */
316 316
     protected function getMultiUnitFieldUnit($field)
317 317
     {
318
-        if (isset($this->{$field.$this->getUnitAttributePostfix()})) {
318
+        if (isset($this->{$field . $this->getUnitAttributePostfix()})) {
319 319
             foreach ($this->getMultiUnitFieldSupportedUnits($field) as $unitClass) {
320 320
                 /**
321 321
                  * @var AbstractUnit $unit
322 322
                  */
323 323
                 $unit = new $unitClass();
324
-                if (strtolower($unit->getId()) == strtolower($this->{$field.$this->getUnitAttributePostfix()})) {
324
+                if (strtolower($unit->getId()) == strtolower($this->{$field . $this->getUnitAttributePostfix()})) {
325 325
                     return $unit;
326 326
                 }
327 327
             }
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
     protected function forgetMultiUnitFieldUnitInput($field)
334 334
     {
335 335
         //prevent column_units to by saved to DB
336
-        if (isset($this->attributes[$field.$this->getUnitAttributePostfix()])) {
337
-            $this->syncOriginalAttribute($field.$this->getUnitAttributePostfix());
336
+        if (isset($this->attributes[$field . $this->getUnitAttributePostfix()])) {
337
+            $this->syncOriginalAttribute($field . $this->getUnitAttributePostfix());
338 338
         }
339 339
     }
340 340
 
341 341
     protected function setMultiUnitFieldUnit($field, AbstractUnit $unit)
342 342
     {
343
-        $this->{$field.$this->getUnitAttributePostfix()} = $unit->getId();
343
+        $this->{$field . $this->getUnitAttributePostfix()} = $unit->getId();
344 344
         $this->forgetMultiUnitFieldUnitInput($field);
345 345
     }
346 346
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -219,13 +219,14 @@
 block discarded – undo
219 219
                     break;
220 220
                 }
221 221
             }
222
-            if($found)
223
-                $this->multiUnitSelectedUnits[$field] = $unitClass;
224
-            else
225
-                throw new NotSupportedMultiUnitFieldUnit($field, $unit);
222
+            if($found) {
223
+                            $this->multiUnitSelectedUnits[$field] = $unitClass;
224
+            } else {
225
+                            throw new NotSupportedMultiUnitFieldUnit($field, $unit);
226
+            }
227
+        } else {
228
+                    throw new NotSupportedMultiUnitField($field);
226 229
         }
227
-        else
228
-            throw new NotSupportedMultiUnitField($field);
229 230
     }
230 231
 
231 232
 
Please login to merge, or discard this patch.