Passed
Push — master ( 5197c9...313b01 )
by Sébastien
04:05 queued 15s
created

MapperPrimaryKey   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 3 1
A name() 0 3 1
1
<?php
2
3
namespace Bdf\Prime\Query\Pagination\WalkStrategy;
4
5
use Bdf\Prime\Mapper\Mapper;
6
7
/**
8
 * Entity primary key extracted from the Mapper
9
 */
10
final class MapperPrimaryKey implements KeyInterface
11
{
12
    /**
13
     * @var Mapper
14
     */
15
    private $mapper;
16
17
    /**
18
     * EntityPrimaryKey constructor.
19
     *
20
     * @param Mapper $mapper
21
     */
22 16
    public function __construct(Mapper $mapper)
23
    {
24 16
        $this->mapper = $mapper;
25 16
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 13
    public function name(): string
31
    {
32 13
        return $this->mapper->metadata()->primary['attributes'][0];
33
    }
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $entity should have a doc-comment as per coding-style.
Loading history...
36
     * {@inheritdoc}
37
     */
38 8
    public function get($entity)
39
    {
40 8
        return $this->mapper->getId($entity);
41
    }
42
}
43