Completed
Pull Request — master (#244)
by Łukasz
09:35
created

DoctrineWorker   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A mount() 0 6 3
1
<?php
2
3
namespace FSi\Bundle\AdminBundle\Factory\Worker;
4
5
use Doctrine\Common\Persistence\ManagerRegistry;
6
use FSi\Bundle\AdminBundle\Admin\Element;
7
use FSi\Bundle\AdminBundle\Doctrine\Admin\DoctrineAwareInterface;
8
use FSi\Bundle\AdminBundle\Doctrine\Admin\Element as DoctrineElement;
9
use FSi\Bundle\AdminBundle\Factory\Worker;
10
11
class DoctrineWorker implements Worker
12
{
13
    /**
14
     * @var ManagerRegistry
15
     */
16
    private $managerRegistry;
17
18
    /**
19
     * @param ManagerRegistry $managerRegistry
20
     */
21
    function __construct(ManagerRegistry $managerRegistry)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
    {
23
        $this->managerRegistry = $managerRegistry;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function mount(Element $element)
30
    {
31
        if ($element instanceof DoctrineAwareInterface || $element instanceof DoctrineElement) {
32
            $element->setManagerRegistry($this->managerRegistry);
33
        }
34
    }
35
}
36