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

MapperPrimaryKey::get()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 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