Passed
Push — master ( 34488c...4ee1ca )
by Maxim
02:53 queued 11s
created

Sum::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 4
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
/**
3
 * @author Igor Pomiluyko <[email protected]>
4
 */
5
6
namespace WS\Utils\Collections\Functions\Group\Aggregator;
7
8
use WS\Utils\Collections\Collection;
9
10
class Sum extends AbstractFieldAggregator implements Aggregator
11
{
12
13 8
    public function __invoke(Collection $collection)
14
    {
15 8
        $sum = 0;
16 8
        foreach ($collection as $element) {
17 7
            $sum += $this->getValue($element);
18
        }
19 8
        return $sum;
20
    }
21
}
22