Passed
Pull Request — master (#20)
by
unknown
03:43
created

First   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 17
ccs 6
cts 7
cp 0.8571
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
namespace WS\Utils\Collections\Functions\Group\Aggregator;
4
5
use WS\Utils\Collections\Functions\ObjectFunctions;
6
7
class First
8
{
9
10
    private $sourceKey;
11
12 6
    public function __construct($sourceKey)
13
    {
14 6
        $this->sourceKey = $sourceKey;
15 6
    }
16
17 6
    public function __invoke(iterable $collection)
18
    {
19 6
        foreach ($collection as $element) {
20 6
            return ObjectFunctions::getPropertyValue($element, $this->sourceKey);
21
        }
22
23
        return null;
24
    }
25
}
26