Completed
Pull Request — master (#71)
by Arnaud
02:45
created

AdminTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 39
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
getUniqueEntity() 0 1 ?
A getPager() 0 4 1
A getUniqueEntityLabel() 0 7 1
1
<?php
2
3
namespace LAG\AdminBundle\Admin\Behaviors;
4
5
use Pagerfanta\Pagerfanta;
6
7
trait AdminTrait
8
{
9
    use EntityLabelTrait;
10
    use TranslationKeyTrait;
11
12
    /**
13
     * @var Pagerfanta
14
     */
15
    protected $pager;
16
17
    /**
18
     * Return the current unique entity.
19
     *
20
     * @return object
21
     */
22
    public abstract function getUniqueEntity();
23
24
    /**
25
     * @return Pagerfanta
26
     */
27
    public function getPager()
28
    {
29
        return $this->pager;
30
    }
31
32
    /**
33
     * Try to find a property to get a label from an entity. If found, it returns the property value through the
34
     * property accessor.
35
     *
36
     * @return string
37
     */
38
    public function getUniqueEntityLabel()
39
    {
40
        $entity = $this->getUniqueEntity();
41
        $label = $this->getEntityLabel($entity);
42
43
        return $label;
44
    }
45
}
46