@@ -6,7 +6,7 @@ discard block |
||
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 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | private function __construct(array $columnValues) |
64 | 64 | { |
65 | - foreach($columnValues as $name => $value) |
|
65 | + foreach ($columnValues as $name => $value) |
|
66 | 66 | { |
67 | 67 | $this->addColumn( |
68 | 68 | (string)$name, |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | ); |
85 | 85 | } |
86 | 86 | |
87 | - public function setFloatValues(bool $enable=true) : Calculator |
|
87 | + public function setFloatValues(bool $enable = true) : Calculator |
|
88 | 88 | { |
89 | 89 | $this->setOption('integerValues', !$enable); |
90 | 90 | return $this; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $max = $this->getMaxMinWidth(); |
104 | 104 | |
105 | - if($width > $max) |
|
105 | + if ($width > $max) |
|
106 | 106 | { |
107 | 107 | throw new \Exception( |
108 | 108 | sprintf('Minimum width cannot be set above %s.', number_format($max, 4)), |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $value |
128 | 128 | ); |
129 | 129 | |
130 | - if($col->isMissing()) |
|
130 | + if ($col->isMissing()) |
|
131 | 131 | { |
132 | 132 | $this->missing++; |
133 | 133 | } |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | |
149 | 149 | private function calculate() : void |
150 | 150 | { |
151 | - if($this->calculated) |
|
151 | + if ($this->calculated) |
|
152 | 152 | { |
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if($this->calcTotal() > $this->maxTotal) |
|
156 | + if ($this->calcTotal() > $this->maxTotal) |
|
157 | 157 | { |
158 | 158 | $this->fixOverflow(); |
159 | 159 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | |
178 | 178 | $result = array(); |
179 | 179 | |
180 | - foreach($this->columns as $col) |
|
180 | + foreach ($this->columns as $col) |
|
181 | 181 | { |
182 | 182 | $val = $col->getValue(); |
183 | 183 | |
184 | - if($this->getBoolOption('integerValues')) |
|
184 | + if ($this->getBoolOption('integerValues')) |
|
185 | 185 | { |
186 | 186 | $val = intval($val); |
187 | 187 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | { |
197 | 197 | $total = 0; |
198 | 198 | |
199 | - foreach($this->columns as $col) |
|
199 | + foreach ($this->columns as $col) |
|
200 | 200 | { |
201 | 201 | $total += $col->getValue(); |
202 | 202 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $leftover = $this->maxTotal - $this->calcTotal(); |
210 | 210 | |
211 | - if($leftover >= 0) |
|
211 | + if ($leftover >= 0) |
|
212 | 212 | { |
213 | 213 | return; |
214 | 214 | } |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | $baseTotal = $this->calcTotalNotMissing(); |
218 | 218 | $min = $this->getMinWidth(); |
219 | 219 | |
220 | - foreach($this->columns as $col) |
|
220 | + foreach ($this->columns as $col) |
|
221 | 221 | { |
222 | - if($col->isMissing()) |
|
222 | + if ($col->isMissing()) |
|
223 | 223 | { |
224 | 224 | continue; |
225 | 225 | } |
226 | 226 | |
227 | - if($leftover <= 0) |
|
227 | + if ($leftover <= 0) |
|
228 | 228 | { |
229 | 229 | break; |
230 | 230 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $amount = round($leftover * $percent / 100); |
234 | 234 | $val = $col->getValue() - $amount; |
235 | 235 | |
236 | - if($val < $min) |
|
236 | + if ($val < $min) |
|
237 | 237 | { |
238 | 238 | continue; |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $col->setValue($val); |
244 | 244 | } |
245 | 245 | |
246 | - if($leftover > 0) |
|
246 | + if ($leftover > 0) |
|
247 | 247 | { |
248 | 248 | $this->removeSurplus(); |
249 | 249 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | { |
254 | 254 | $total = 0; |
255 | 255 | |
256 | - foreach($this->columns as $col) |
|
256 | + foreach ($this->columns as $col) |
|
257 | 257 | { |
258 | - if(!$col->isMissing()) |
|
258 | + if (!$col->isMissing()) |
|
259 | 259 | { |
260 | 260 | $total += $col->getValue(); |
261 | 261 | } |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | $leftover = $this->maxTotal - $this->calcTotal(); |
278 | 278 | $perCol = $leftover / $this->amountCols; |
279 | 279 | |
280 | - if($this->getBoolOption('integerValues')) |
|
280 | + if ($this->getBoolOption('integerValues')) |
|
281 | 281 | { |
282 | 282 | $perCol = (int)ceil($perCol); |
283 | 283 | } |
284 | 284 | |
285 | - for($i=($this->amountCols-1); $i >=0; $i--) |
|
285 | + for ($i = ($this->amountCols - 1); $i >= 0; $i--) |
|
286 | 286 | { |
287 | - if($leftover <= 0) |
|
287 | + if ($leftover <= 0) |
|
288 | 288 | { |
289 | 289 | break; |
290 | 290 | } |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | private function adjustLeftoverValues() : void |
308 | 308 | { |
309 | 309 | // convert all columns to integer values as required |
310 | - if($this->getBoolOption('integerValues')) |
|
310 | + if ($this->getBoolOption('integerValues')) |
|
311 | 311 | { |
312 | - foreach($this->columns as $col) |
|
312 | + foreach ($this->columns as $col) |
|
313 | 313 | { |
314 | 314 | $val = intval(floor($col->getValue())); |
315 | 315 | $col->setValue(floatval($val)); |
@@ -319,23 +319,23 @@ discard block |
||
319 | 319 | |
320 | 320 | private function fillMissing() : void |
321 | 321 | { |
322 | - if($this->missing === 0) |
|
322 | + if ($this->missing === 0) |
|
323 | 323 | { |
324 | 324 | return; |
325 | 325 | } |
326 | 326 | |
327 | 327 | $toDistribute = $this->maxTotal - $this->calcTotal(); |
328 | 328 | |
329 | - if($toDistribute <= 0) |
|
329 | + if ($toDistribute <= 0) |
|
330 | 330 | { |
331 | 331 | $toDistribute = $this->getMinWidth() * $this->missing; |
332 | 332 | } |
333 | 333 | |
334 | 334 | $perMissingCol = $toDistribute / $this->missing; |
335 | 335 | |
336 | - foreach($this->columns as $col) |
|
336 | + foreach ($this->columns as $col) |
|
337 | 337 | { |
338 | - if($col->isMissing()) |
|
338 | + if ($col->isMissing()) |
|
339 | 339 | { |
340 | 340 | $col->setValue($perMissingCol); |
341 | 341 | } |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | // are not missing. |
352 | 352 | $maxTotal = $this->maxTotal / ($this->amountCols - $this->missing); |
353 | 353 | |
354 | - foreach($this->columns as $col) |
|
354 | + foreach ($this->columns as $col) |
|
355 | 355 | { |
356 | 356 | // no change for missing columns, they get filled later |
357 | - if($col->isMissing()) |
|
357 | + if ($col->isMissing()) |
|
358 | 358 | { |
359 | 359 | continue; |
360 | 360 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @see Mistralys\WidthsCalculator\Calculator\Column |
7 | 7 | */ |
8 | 8 | |
9 | -declare (strict_types=1); |
|
9 | +declare(strict_types=1); |
|
10 | 10 | |
11 | 11 | namespace Mistralys\WidthsCalculator\Calculator; |
12 | 12 |