Conditions | 3 |
Paths | 3 |
Total Lines | 23 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | public function fix() : void |
||
34 | { |
||
35 | $total = $this->operations->calcTotal(); |
||
36 | |||
37 | // to allow space for the missing columns, we base the |
||
38 | // total target percentage on the amount of columns that |
||
39 | // are not missing. |
||
40 | $maxTotal = $this->calculator->getMaxTotal() / ($this->operations->countColumns() - $this->operations->countMissing()); |
||
41 | |||
42 | $cols = $this->calculator->getColumns(); |
||
43 | |||
44 | foreach($cols as $col) |
||
45 | { |
||
46 | // no change for missing columns, they get filled later |
||
47 | if($col->isMissing()) |
||
48 | { |
||
49 | continue; |
||
50 | } |
||
51 | |||
52 | $percentage = $col->getValue() * 100 / $total; |
||
53 | $adjusted = floor($maxTotal * $percentage / 100); |
||
54 | |||
55 | $col->setValue((int)$adjusted); |
||
56 | } |
||
59 |