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

AutoKeyedMap::insertItem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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