Passed
Pull Request — master (#20)
by Igor
03:14
created

Sum   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 0
Metric Value
eloc 5
c 5
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
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