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