Passed
Push — master ( a4571b...162929 )
by Chris
07:18
created

AutoKeyedMap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A insertItem() 0 3 1
1
<?php
2
3
namespace WebTheory\Collection\Driver;
4
5
use WebTheory\Collection\Contracts\ArrayDriverInterface;
6
use WebTheory\Collection\Contracts\ObjectComparatorInterface;
7
use WebTheory\Collection\Contracts\PropertyResolverInterface;
8
use WebTheory\Collection\Driver\Abstracts\AbstractArrayDriver;
9
use WebTheory\Collection\Resolution\Abstracts\ResolvesPropertyValueTrait;
10
11
class AutoKeyedMap extends AbstractArrayDriver implements ArrayDriverInterface
12
{
13
    use ResolvesPropertyValueTrait;
14
15 69
    public function __construct(
16
        string $property,
17
        PropertyResolverInterface $propertyResolver,
18
        ObjectComparatorInterface $objectComparator
19
    ) {
20 69
        $this->property = $property;
21 69
        $this->propertyResolver = $propertyResolver;
22 69
        $this->objectComparator = $objectComparator;
23
    }
24
25 69
    public function insertItem(array &$array, object $item, $offset = null): void
26
    {
27 69
        $array[$this->resolveValue($item)] = $item;
28
    }
29
}
30