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

Max   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 4
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 Max extends AbstractFieldAggregator implements Aggregator
11
{
12
13 8
    public function __invoke(Collection $collection)
14
    {
15 8
        $max = null;
16 8
        foreach ($collection as $element) {
17 7
            $value = $this->getValue($element);
18 7
            if ($max === null || $max < $value) {
19 7
                $max = $value;
20
            }
21
        }
22 8
        return $max;
23
    }
24
}
25