@@ -30,9 +30,9 @@ discard block |
||
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) |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | $this->cleanUp($leftover); |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * In integer mode, after filling all items, because of rounding |
|
76 | - * the amount of column up, we may have added a bit too much. We |
|
77 | - * fix this here, by removing it from the last column. |
|
78 | - * |
|
79 | - * @param float $leftover |
|
80 | - */ |
|
74 | + /** |
|
75 | + * In integer mode, after filling all items, because of rounding |
|
76 | + * the amount of column up, we may have added a bit too much. We |
|
77 | + * fix this here, by removing it from the last column. |
|
78 | + * |
|
79 | + * @param float $leftover |
|
80 | + */ |
|
81 | 81 | private function cleanUp(float $leftover) : void |
82 | 82 | { |
83 | 83 | if($leftover >= 0) |
@@ -6,7 +6,7 @@ discard block |
||
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 |
||
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 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function cleanUp(float $leftover) : void |
82 | 82 | { |
83 | - if($leftover >= 0) |
|
83 | + if ($leftover >= 0) |
|
84 | 84 | { |
85 | 85 | return; |
86 | 86 | } |
@@ -37,24 +37,24 @@ discard block |
||
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 |
||
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( |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | return $this; |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Sets the minimum width to enforce for columns, |
|
118 | - * when there already are other columns that take |
|
119 | - * up all the available width. |
|
120 | - * |
|
121 | - * @param float $width |
|
122 | - * @return Calculator |
|
123 | - */ |
|
116 | + /** |
|
117 | + * Sets the minimum width to enforce for columns, |
|
118 | + * when there already are other columns that take |
|
119 | + * up all the available width. |
|
120 | + * |
|
121 | + * @param float $width |
|
122 | + * @return Calculator |
|
123 | + */ |
|
124 | 124 | public function setMinWidth(float $width) : Calculator |
125 | 125 | { |
126 | 126 | $max = $this->getMaxMinWidth(); |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | $this->columns[] = $col; |
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * Retrieves the minimum width for columns, in percent. |
|
158 | - * @return float |
|
159 | - */ |
|
156 | + /** |
|
157 | + * Retrieves the minimum width for columns, in percent. |
|
158 | + * @return float |
|
159 | + */ |
|
160 | 160 | public function getMinWidth() : float |
161 | 161 | { |
162 | 162 | return floatval($this->getOption('minPerCol')); |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | $this->calculated = true; |
183 | 183 | } |
184 | 184 | |
185 | - /** |
|
186 | - * Adjusts the individual column values to match |
|
187 | - * the expected output format, for example ensuring |
|
188 | - * integer values if we are in integer mode. |
|
189 | - */ |
|
185 | + /** |
|
186 | + * Adjusts the individual column values to match |
|
187 | + * the expected output format, for example ensuring |
|
188 | + * integer values if we are in integer mode. |
|
189 | + */ |
|
190 | 190 | private function convertToInteger() : void |
191 | 191 | { |
192 | 192 | // convert all columns to integer values as required |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - /** |
|
204 | - * Retrieves the updated list of column values, |
|
205 | - * retaining the original keys. |
|
206 | - * |
|
207 | - * @return array<string,int|float> |
|
208 | - */ |
|
203 | + /** |
|
204 | + * Retrieves the updated list of column values, |
|
205 | + * retaining the original keys. |
|
206 | + * |
|
207 | + * @return array<string,int|float> |
|
208 | + */ |
|
209 | 209 | public function getValues() : array |
210 | 210 | { |
211 | 211 | $this->calculate(); |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | return $this->getBoolOption('integerValues'); |
233 | 233 | } |
234 | 234 | |
235 | - /** |
|
236 | - * Retrieves the column values as pixel values, based on |
|
237 | - * the target available pixel width. |
|
238 | - * |
|
239 | - * @param int $targetWidth |
|
240 | - * @return array<string,int> |
|
241 | - */ |
|
235 | + /** |
|
236 | + * Retrieves the column values as pixel values, based on |
|
237 | + * the target available pixel width. |
|
238 | + * |
|
239 | + * @param int $targetWidth |
|
240 | + * @return array<string,int> |
|
241 | + */ |
|
242 | 242 | public function getPixelValues(int $targetWidth) : array |
243 | 243 | { |
244 | 244 | $calc = Calculator::create($this->getValues()); |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | return $calc->getValues(); |
248 | 248 | } |
249 | 249 | |
250 | - /** |
|
251 | - * @return Column[] |
|
252 | - */ |
|
250 | + /** |
|
251 | + * @return Column[] |
|
252 | + */ |
|
253 | 253 | public function getColumns() : array |
254 | 254 | { |
255 | 255 | return $this->columns; |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | $surplus->remove(); |
262 | 262 | } |
263 | 263 | |
264 | - /** |
|
265 | - * Detects any leftover percentages that still need |
|
266 | - * to be filled, in case we are not at 100% yet. It |
|
267 | - * distributes the missing percentages evenly over the |
|
268 | - * available columns, from the last one upwards. |
|
269 | - */ |
|
264 | + /** |
|
265 | + * Detects any leftover percentages that still need |
|
266 | + * to be filled, in case we are not at 100% yet. It |
|
267 | + * distributes the missing percentages evenly over the |
|
268 | + * available columns, from the last one upwards. |
|
269 | + */ |
|
270 | 270 | private function fillLeftover() : void |
271 | 271 | { |
272 | 272 | $filler = new LeftoverFiller($this); |