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