Completed
Pull Request — master (#16)
by Maksim
01:34
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/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
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -116,8 +116,9 @@
 block discarded – undo
116 116
      */
117 117
     private function calculateMultiUnitConversionData($value, AbstractUnit $unit, $requiredUnits)
118 118
     {
119
-        if(is_null($value))
120
-            return null;
119
+        if(is_null($value)) {
120
+                    return null;
121
+        }
121 122
 
122 123
         $conversionData = [];
123 124
         foreach ($requiredUnits as $requiredUnitClass) {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     private function getUnitConversionDataColumns()
21 21
     {
22 22
         return array_map(function ($column) {
23
-            return $column.$this->getUnitConversionDataPostfix();
23
+            return $column . $this->getUnitConversionDataPostfix();
24 24
         }, array_keys($this->getMultiUnitColumns()));
25 25
     }
26 26
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
              */
34 34
             foreach ($model->getMultiUnitColumns() as $unitBasedColumn => $options) {
35 35
                 if (isset($model->attributes[$unitBasedColumn])) {
36
-                    $model->{$unitBasedColumn.$model->getUnitConversionDataPostfix()} = json_encode(
36
+                    $model->{$unitBasedColumn . $model->getUnitConversionDataPostfix()} = json_encode(
37 37
                         $model->calculateMultiUnitConversionData(
38 38
                             $model->attributes[$unitBasedColumn],
39 39
                             $model->getMultiUnitFieldUnit($unitBasedColumn),
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
              * @var Model|MultiUnitSupport $model
53 53
              */
54 54
             foreach (Arr::only($model->getMultiUnitColumns(), array_keys($model->getDirty())) as $unitBasedColumn => $options) {
55
-                $model->{$unitBasedColumn.$model->getUnitConversionDataPostfix()} = json_encode(
55
+                $model->{$unitBasedColumn . $model->getUnitConversionDataPostfix()} = json_encode(
56 56
                     $model->calculateMultiUnitConversionData(
57 57
                         $model->getDirty()[$unitBasedColumn],
58 58
                         $model->getMultiUnitFieldUnit($unitBasedColumn, true),
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     private function calculateMultiUnitConversionData($value, AbstractUnit $unit, $requiredUnits)
74 74
     {
75
-        if(is_null($value))
75
+        if (is_null($value))
76 76
             return null;
77 77
 
78 78
         $conversionData = [];
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
     public function getMultiUnitExistingConversionData($field)
91 91
     {
92
-        return json_decode($this->{$field.$this->getUnitConversionDataPostfix()} ?? null);
92
+        return json_decode($this->{$field . $this->getUnitConversionDataPostfix()} ?? null);
93 93
     }
94 94
 
95 95
     /**
Please login to merge, or discard this patch.
src/Traits/ModelConfiguration.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
      */
158 158
     private function processMultiUnitFieldChanges($field, $value)
159 159
     {
160
-        if(!is_null($value)) {
160
+        if (!is_null($value)) {
161 161
             $existingConversionData = $this->getMultiUnitExistingConversionData($field);
162 162
             if (!is_null($existingConversionData)) {
163 163
                 $inputUnit = $this->getMultiUnitFieldUnit($field);
Please login to merge, or discard this patch.