Conditions | 3 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 3.0123 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | 7 | public function __invoke(Collection $collection) |
|
19 | { |
||
20 | 7 | $acc = null; |
|
21 | 7 | $cnt = 0; |
|
22 | 7 | foreach ($collection as $element) { |
|
23 | 7 | $acc += ObjectFunctions::getPropertyValue($element, $this->fieldName); |
|
24 | 6 | $cnt++; |
|
25 | } |
||
26 | 6 | if (!$cnt) { |
|
27 | return null; |
||
28 | } |
||
29 | 6 | return $acc / $cnt; |
|
30 | } |
||
32 |