AbstractResourceType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 44
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A setObjectManager() 0 5 1
A __construct() 0 6 1
1
<?php
2
3
namespace DoS\ResourceBundle\Form\Type;
4
5
use Doctrine\Common\Persistence\ObjectManager;
6
use Doctrine\Common\Persistence\ObjectRepository;
7
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType as BaseAbstractResourceType;
8
9
abstract class AbstractResourceType extends BaseAbstractResourceType
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name;
15
16
    /**
17
     * @var ObjectManager
18
     */
19
    protected $manager;
20
21
    /**
22
     * @var ObjectRepository
23
     */
24
    protected $repository;
25
26
    /**
27
     * @param ObjectManager|null $manager
28
     */
29
    public function setObjectManager(ObjectManager $manager = null)
30
    {
31
        $this->manager = $manager;
32
        $this->repository = $manager->getRepository($this->dataClass);
0 ignored issues
show
Bug introduced by
It seems like $manager is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function __construct($dataClass, array $validationGroups = array(), $name = null)
39
    {
40
        parent::__construct($dataClass, $validationGroups);
41
42
        $this->name = $name;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getName()
49
    {
50
        return $this->name;
51
    }
52
}
53