Passed
Push — master ( 0692ec...4950c9 )
by Sebastian
02:38 queued 11s
created
src/Calculator.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
     
38 38
     use Traits_Optionable;
39 39
     
40
-   /**
41
-    * @var Column[]
42
-    */
40
+    /**
41
+     * @var Column[]
42
+     */
43 43
     private $columns = array();
44 44
     
45
-   /**
46
-    * @var boolean
47
-    */
45
+    /**
46
+     * @var boolean
47
+     */
48 48
     private $calculated = false;
49 49
     
50
-   /**
51
-    * @var Operations
52
-    */
50
+    /**
51
+     * @var Operations
52
+     */
53 53
     private $operations;
54 54
     
55
-   /**
56
-    * @param array<string,float> $columnValues
57
-    */
55
+    /**
56
+     * @param array<string,float> $columnValues
57
+     */
58 58
     private function __construct(array $columnValues)
59 59
     {
60 60
         foreach($columnValues as $name => $value)
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
         $this->operations = new Operations($this);
69 69
     }
70 70
     
71
-   /**
72
-    * Creates an instance of the calculator.
73
-    * 
74
-    * @param array<string,float> $columnValues
75
-    * @return Calculator
76
-    */
71
+    /**
72
+     * Creates an instance of the calculator.
73
+     * 
74
+     * @param array<string,float> $columnValues
75
+     * @return Calculator
76
+     */
77 77
     public static function create(array $columnValues) : Calculator
78 78
     {
79 79
         return new Calculator($columnValues);
80 80
     }
81 81
     
82
-   /**
83
-    * @return array<string,mixed>
84
-    */
82
+    /**
83
+     * @return array<string,mixed>
84
+     */
85 85
     public function getDefaultOptions(): array
86 86
     {
87 87
         return array(
@@ -107,14 +107,14 @@  discard block
 block discarded – undo
107 107
         return $this;
108 108
     }
109 109
     
110
-   /**
111
-    * Sets the minimum width to enforce for columns, 
112
-    * when there already are other columns that take
113
-    * up all the available width.
114
-    * 
115
-    * @param float $width
116
-    * @return Calculator
117
-    */
110
+    /**
111
+     * Sets the minimum width to enforce for columns, 
112
+     * when there already are other columns that take
113
+     * up all the available width.
114
+     * 
115
+     * @param float $width
116
+     * @return Calculator
117
+     */
118 118
     public function setMinWidth(float $width) : Calculator
119 119
     {
120 120
         $max = $this->getMaxMinWidth();
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
         $this->columns[] = $col;
148 148
     }
149 149
     
150
-   /**
151
-    * Retrieves the minimum width for columns, in percent.
152
-    * @return float
153
-    */
150
+    /**
151
+     * Retrieves the minimum width for columns, in percent.
152
+     * @return float
153
+     */
154 154
     public function getMinWidth() : float
155 155
     {
156 156
         return floatval($this->getOption('minPerCol'));
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
         $this->calculated = true;
177 177
     }
178 178
     
179
-   /**
180
-    * Adjusts the individual column values to match
181
-    * the expected output format, for example ensuring
182
-    * integer values if we are in integer mode.
183
-    */
179
+    /**
180
+     * Adjusts the individual column values to match
181
+     * the expected output format, for example ensuring
182
+     * integer values if we are in integer mode.
183
+     */
184 184
     private function convertToInteger() : void
185 185
     {
186 186
         // convert all columns to integer values as required
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
         }
195 195
     }
196 196
     
197
-   /**
198
-    * Retrieves the updated list of column values, 
199
-    * retaining the original keys.
200
-    * 
201
-    * @return array<string,int|float>
202
-    */
197
+    /**
198
+     * Retrieves the updated list of column values, 
199
+     * retaining the original keys.
200
+     * 
201
+     * @return array<string,int|float>
202
+     */
203 203
     public function getValues() : array
204 204
     {
205 205
         $this->calculate();
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
         return $this->getBoolOption('integerValues');
227 227
     }
228 228
     
229
-   /**
230
-    * @return Column[]
231
-    */
229
+    /**
230
+     * @return Column[]
231
+     */
232 232
     public function getColumns() : array 
233 233
     {
234 234
         return $this->columns;
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
         $surplus->remove();
241 241
     }
242 242
     
243
-   /**
244
-    * Detects any leftover percentages that still need
245
-    * to be filled, in case we are not at 100% yet. It
246
-    * distributes the missing percentages evenly over the
247
-    * available columns, from the last one upwards.
248
-    */
243
+    /**
244
+     * Detects any leftover percentages that still need
245
+     * to be filled, in case we are not at 100% yet. It
246
+     * distributes the missing percentages evenly over the
247
+     * available columns, from the last one upwards.
248
+     */
249 249
     private function fillLeftover() : void
250 250
     {
251 251
         $filler = new LeftoverFiller($this);
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator;
12 12
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     */
58 58
     private function __construct(array $columnValues)
59 59
     {
60
-        foreach($columnValues as $name => $value)
60
+        foreach ($columnValues as $name => $value)
61 61
         {
62 62
             $this->addColumn(
63 63
                 (string)$name, 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
         return $this->operations;
102 102
     }
103 103
     
104
-    public function setFloatValues(bool $enable=true) : Calculator
104
+    public function setFloatValues(bool $enable = true) : Calculator
105 105
     {
106 106
         $this->setOption('integerValues', !$enable);
107 107
         return $this;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
     {
120 120
         $max = $this->getMaxMinWidth();
121 121
         
122
-        if($width > $max)
122
+        if ($width > $max)
123 123
         {
124 124
             throw new \Exception(
125 125
                 sprintf('Minimum width cannot be set above %s.', number_format($max, 4)),
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
     
159 159
     private function calculate() : void
160 160
     {
161
-        if($this->calculated)
161
+        if ($this->calculated)
162 162
         {
163 163
             return;
164 164
         }
165 165
         
166
-        if($this->operations->calcTotal() > $this->getMaxTotal())
166
+        if ($this->operations->calcTotal() > $this->getMaxTotal())
167 167
         {
168 168
             $this->fixOverflow();
169 169
         }
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
     private function convertToInteger() : void
185 185
     {
186 186
         // convert all columns to integer values as required
187
-        if($this->isIntegerMode())
187
+        if ($this->isIntegerMode())
188 188
         {
189
-            foreach($this->columns as $col)
189
+            foreach ($this->columns as $col)
190 190
             {
191 191
                 $val = intval(floor($col->getValue()));
192 192
                 $col->setValue(floatval($val));
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
         
207 207
         $result = array();
208 208
         
209
-        foreach($this->columns as $col)
209
+        foreach ($this->columns as $col)
210 210
         {
211 211
             $val = $col->getValue();
212 212
             
213
-            if($this->isIntegerMode())
213
+            if ($this->isIntegerMode())
214 214
             {
215 215
                 $val = intval($val);
216 216
             }
Please login to merge, or discard this patch.
src/Calculator/LeftoverFiller.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
      */
31 31
     private $operations;
32 32
     
33
-   /**
34
-    * @var Column[]
35
-    */
33
+    /**
34
+     * @var Column[]
35
+     */
36 36
     private $columns = array();
37 37
     
38 38
     public function __construct(Calculator $calculator)
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator\LeftoverFiller
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator\Calculator;
12 12
 
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
         $leftover = $this->calculator->getMaxTotal() - $this->operations->calcTotal();
48 48
         $perCol = $leftover / $this->operations->countColumns();
49 49
         
50
-        if($this->calculator->isIntegerMode())
50
+        if ($this->calculator->isIntegerMode())
51 51
         {
52 52
             $perCol = (int)ceil($perCol);
53 53
         }
54 54
         
55
-        for($i=($this->operations->countColumns()-1); $i >=0; $i--)
55
+        for ($i = ($this->operations->countColumns() - 1); $i >= 0; $i--)
56 56
         {
57
-            if($leftover <= 0)
57
+            if ($leftover <= 0)
58 58
             {
59 59
                 break;
60 60
             }
Please login to merge, or discard this patch.
src/Calculator/OverflowFixer.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@
 block discarded – undo
21 21
  */
22 22
 class  OverflowFixer
23 23
 {
24
-   /**
25
-    * @var Calculator
26
-    */
24
+    /**
25
+     * @var Calculator
26
+     */
27 27
     private $calculator;
28 28
     
29
-   /**
30
-    * @var Operations
31
-    */
29
+    /**
30
+     * @var Operations
31
+     */
32 32
     private $operations;
33 33
     
34 34
     public function __construct(Calculator $calculator)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator\OverflowFixer
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator\Calculator;
12 12
 
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
         
49 49
         $cols = $this->calculator->getColumns();
50 50
         
51
-        foreach($cols as $col)
51
+        foreach ($cols as $col)
52 52
         {
53 53
             // no change for missing columns, they get filled later
54
-            if($col->isMissing())
54
+            if ($col->isMissing())
55 55
             {
56 56
                 continue;
57 57
             }
Please login to merge, or discard this patch.
src/Calculator/SurplusRemover.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@
 block discarded – undo
32 32
      */
33 33
     private $operations;
34 34
     
35
-   /**
36
-    * @var float
37
-    */
35
+    /**
36
+     * @var float
37
+     */
38 38
     private $leftover = 0;
39 39
     
40
-   /**
41
-    * @var float
42
-    */
40
+    /**
41
+     * @var float
42
+     */
43 43
     private $baseTotal = 0;
44 44
     
45 45
     public function __construct(Calculator $calculator)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator\SurplusRemover
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator\Calculator;
12 12
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $this->leftover = $this->calculator->getMaxTotal() - $this->operations->calcTotal();
54 54
         
55
-        if($this->leftover >= 0)
55
+        if ($this->leftover >= 0)
56 56
         {
57 57
             return;
58 58
         }
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
         $this->baseTotal = $this->operations->calcTotalNotMissing();
62 62
         $cols = $this->calculator->getColumns();
63 63
         
64
-        foreach($cols as $col)
64
+        foreach ($cols as $col)
65 65
         {
66
-            if(!$this->processColumn($col))
66
+            if (!$this->processColumn($col))
67 67
             {
68 68
                 break;
69 69
             }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         //
77 77
         // We simply run the removal again, to remove the 
78 78
         // surplus from the columns it can be removed from.
79
-        if($this->leftover > 0)
79
+        if ($this->leftover > 0)
80 80
         {
81 81
             $this->remove();
82 82
         }
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
     
85 85
     private function processColumn(Column $col) : bool
86 86
     {
87
-        if($col->isMissing())
87
+        if ($col->isMissing())
88 88
         {
89 89
             return true;
90 90
         }
91 91
         
92
-        if($this->leftover <= 0)
92
+        if ($this->leftover <= 0)
93 93
         {
94 94
             return false;
95 95
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $amount = round($this->leftover * $percent / 100);
99 99
         $val = $col->getValue() - $amount;
100 100
         
101
-        if($val < $this->calculator->getMinWidth())
101
+        if ($val < $this->calculator->getMinWidth())
102 102
         {
103 103
             return true;
104 104
         }
Please login to merge, or discard this patch.
src/Calculator/Operations.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@
 block discarded – undo
36 36
      */
37 37
     private $missing = 0;
38 38
     
39
-   /**
40
-    * @var Column[]
41
-    */
39
+    /**
40
+     * @var Column[]
41
+     */
42 42
     private $columns = array();
43 43
     
44 44
     public function __construct(Calculator $calculator)
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator\Operations
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator\Calculator;
12 12
 
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
         $this->columns = $calculator->getColumns();
48 48
         $this->amountCols = count($this->columns);
49 49
         
50
-        foreach($this->columns as $col)
50
+        foreach ($this->columns as $col)
51 51
         {
52
-            if($col->isMissing())
52
+            if ($col->isMissing())
53 53
             {
54 54
                 $this->missing++;
55 55
             }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $total = 0;
62 62
         
63
-        foreach($this->columns as $col)
63
+        foreach ($this->columns as $col)
64 64
         {
65 65
             $total += $col->getValue();
66 66
         }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
     {
83 83
         $total = 0;
84 84
         
85
-        foreach($this->columns as $col)
85
+        foreach ($this->columns as $col)
86 86
         {
87
-            if(!$col->isMissing())
87
+            if (!$col->isMissing())
88 88
             {
89 89
                 $total += $col->getValue();
90 90
             }
Please login to merge, or discard this patch.
src/Calculator/MissingFiller.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@
 block discarded – undo
30 30
      */
31 31
     private $operations;
32 32
     
33
-   /**
34
-    * @var integer
35
-    */
33
+    /**
34
+     * @var integer
35
+     */
36 36
     private $missing = 0;
37 37
     
38 38
     public function __construct(Calculator $calculator)
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @see Mistralys\WidthsCalculator\Calculator\MissingFiller
7 7
  */
8 8
 
9
-declare (strict_types=1);
9
+declare(strict_types=1);
10 10
 
11 11
 namespace Mistralys\WidthsCalculator\Calculator;
12 12
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     
45 45
     public function fill() : void
46 46
     {
47
-        if($this->missing === 0)
47
+        if ($this->missing === 0)
48 48
         {
49 49
             return;
50 50
         }
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $cols = $this->calculator->getColumns();
60 60
         
61
-        foreach($cols as $col)
61
+        foreach ($cols as $col)
62 62
         {
63
-            if($col->isMissing())
63
+            if ($col->isMissing())
64 64
             {
65 65
                 $col->setValue($perColumn);
66 66
             }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $toDistribute = $this->calculator->getMaxTotal() - $this->operations->calcTotal();
73 73
         
74
-        if($toDistribute <= 0)
74
+        if ($toDistribute <= 0)
75 75
         {
76 76
             $toDistribute = $this->calculator->getMinWidth() * $this->missing;
77 77
         }
Please login to merge, or discard this patch.