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

First   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 4
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 First extends AbstractFieldAggregator implements Aggregator
11
{
12
13 6
    public function __invoke(Collection $collection)
14
    {
15 6
        if (!$first = $collection->stream()->findFirst()) {
16 1
            return null;
17
        }
18
19 5
        return $this->getValue($first);
20
    }
21
}
22