Completed
Pull Request — master (#11)
by Maksim
02:18 queued 01:00
created
src/Exceptions/NotSupportedMultiUnitField.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, $code = 0, Throwable $previous = null)
10 10
     {
11
-        parent::__construct('Requested field "'.$field.'" is not multi-unit field', $code, $previous);
11
+        parent::__construct('Requested field "' . $field . '" is not multi-unit field', $code, $previous);
12 12
     }
13 13
 }
Please login to merge, or discard this patch.
src/MultiUnitModelsServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         if ($this->app->runningInConsole()) {
21 21
             if (!str_contains($this->app->version(), 'Lumen')) {
22 22
                 $this->publishes([
23
-                    __DIR__.'/../config/multi-units.php' => config_path('multi-units.php'),
23
+                    __DIR__ . '/../config/multi-units.php' => config_path('multi-units.php'),
24 24
                 ], 'config');
25 25
             }
26 26
         }
@@ -50,6 +50,6 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function register()
52 52
     {
53
-        $this->mergeConfigFrom(__DIR__.'/../config/multi-units.php', 'multi-units');
53
+        $this->mergeConfigFrom(__DIR__ . '/../config/multi-units.php', 'multi-units');
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
src/Traits/MultiUnitSupport.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@
 block discarded – undo
166 166
     }
167 167
 
168 168
     /**
169
-     * @param                   $field
169
+     * @param                   string $field
170 170
      * @param AbstractUnit|null $unit
171 171
      *
172 172
      * @throws NotSupportedMultiUnitField
Please login to merge, or discard this patch.
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, true),
@@ -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(
94
+                $model->{$unitBasedColumn . $model->getUnitConversionDataPostfix()} = json_encode(
95 95
                     $model->calculateMultiUnitConversionData(
96 96
                         $model->getDirty()[$unitBasedColumn],
97 97
                         $model->getMultiUnitFieldUnit($unitBasedColumn, true),
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 
126 126
     public function getMultiUnitExistingConversionData($field)
127 127
     {
128
-        return json_decode($this->{$field.$this->getUnitConversionDataPostfix()} ?? null);
128
+        return json_decode($this->{$field . $this->getUnitConversionDataPostfix()} ?? null);
129 129
     }
130 130
 
131 131
     /**
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
      */
322 322
     protected function getMultiUnitFieldUnit($field, $preferDefault = false)
323 323
     {
324
-        if (isset($this->{$field.$this->getUnitAttributePostfix()})) {
324
+        if (isset($this->{$field . $this->getUnitAttributePostfix()})) {
325 325
             foreach ($this->getMultiUnitFieldSupportedUnits($field) as $unitClass) {
326 326
                 /**
327 327
                  * @var AbstractUnit $unit
328 328
                  */
329 329
                 $unit = new $unitClass();
330
-                if (strtolower($unit->getId()) == strtolower($this->{$field.$this->getUnitAttributePostfix()})) {
330
+                if (strtolower($unit->getId()) == strtolower($this->{$field . $this->getUnitAttributePostfix()})) {
331 331
                     return $unit;
332 332
                 }
333 333
             }
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
     protected function forgetMultiUnitFieldUnitInput($field)
340 340
     {
341 341
         //prevent column_units to by saved to DB
342
-        if (isset($this->attributes[$field.$this->getUnitAttributePostfix()])) {
343
-            $this->syncOriginalAttribute($field.$this->getUnitAttributePostfix());
342
+        if (isset($this->attributes[$field . $this->getUnitAttributePostfix()])) {
343
+            $this->syncOriginalAttribute($field . $this->getUnitAttributePostfix());
344 344
         }
345 345
     }
346 346
 
347 347
     protected function setMultiUnitFieldUnit($field, AbstractUnit $unit)
348 348
     {
349
-        if (isset($this->{$field.$this->getUnitAttributePostfix()})) {
350
-            $this->{$field.$this->getUnitAttributePostfix()} = $unit->getId();
349
+        if (isset($this->{$field . $this->getUnitAttributePostfix()})) {
350
+            $this->{$field . $this->getUnitAttributePostfix()} = $unit->getId();
351 351
         }
352 352
         $this->forgetMultiUnitFieldUnitInput($field);
353 353
     }
Please login to merge, or discard this patch.
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.