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 |
||
17 | 7 | public function __invoke(iterable $collection) |
|
18 | { |
||
19 | 7 | $acc = null; |
|
20 | 7 | $cnt = 0; |
|
21 | 7 | foreach ($collection as $element) { |
|
22 | 7 | $acc += ObjectFunctions::getPropertyValue($element, $this->sourceKey); |
|
23 | 6 | $cnt++; |
|
24 | } |
||
25 | 6 | if (!$cnt) { |
|
26 | return null; |
||
27 | } |
||
28 | 6 | return $acc / $cnt; |
|
29 | } |
||
31 |