Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
83.33% |
5 / 6 |
| SumReducerTrait | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
3.04 | |
83.33% |
5 / 6 |
| reduceMethod | |
0.00% |
0 / 1 |
3.04 | |
83.33% |
5 / 6 |
|||
| <?php | |
| namespace Alxvng\QATracker\DataProvider\Reducer; | |
| trait SumReducerTrait | |
| { | |
| public function reduceMethod(array $nodes): float | |
| { | |
| $sum = 0; | |
| foreach ($nodes as $node) { | |
| if (!is_numeric((string) $node)) { | |
| throw new \RuntimeException(sprintf('The result of must be a numeric value, got "%s"', $node)); | |
| } | |
| $sum += (float) $node; | |
| } | |
| return round($sum, 2); | |
| } | |
| } |