Passed
Push — master ( 2f6942...d6d802 )
by Chris
28:11
created

AutoKeyedMapTrait::insert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
namespace WebTheory\Collection\Access\Abstracts;
4
5
trait AutoKeyedMapTrait
6
{
7 69
    public function insert(array &$array, object $item, $offset = null): bool
0 ignored issues
show
Unused Code introduced by
The parameter $offset is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

7
    public function insert(array &$array, object $item, /** @scrutinizer ignore-unused */ $offset = null): bool

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
8
    {
9 69
        $key = $this->getObjectAsKey($item);
10
11 69
        if (isset($array[$key])) {
12 3
            return false;
13
        }
14
15 69
        $array[$key] = $item;
16
17 69
        return true;
18
    }
19
20
    abstract protected function getObjectAsKey(object $item): string;
21
}
22