MultipleRole::getRoles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace JhUserTest\Fixture;
4
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\Persistence\ObjectManager;
7
use JhUser\Entity\HierarchicalRole;
8
9
/**
10
 * Class MultipleRole
11
 * @package JhUserTest\Fixture
12
 * @author Aydin Hassan <[email protected]>
13
 */
14
class MultipleRole extends AbstractFixture
15
{
16
    /**
17
     * @var Role[]
18
     */
19
    protected $roles;
20
21
    /**
22
     * @var Role
23
     */
24
    protected $parent;
25
26
    /**
27
     * {inheritDoc}
28
     */
29
    public function load(ObjectManager $manager)
30
    {
31
32
        $parent = new HierarchicalRole();
33
        $parent->setName('user');
34
        $manager->persist($parent);
35
        $this->parent = $parent;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parent of type object<JhUser\Entity\HierarchicalRole> is incompatible with the declared type object<JhUserTest\Fixture\Role> of property $parent.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
36
37
        foreach (['admin', 'manager'] as $roleData) {
38
            $role = new HierarchicalRole;
39
            $role->setName($roleData);
40
41
            $parent->addChild($role);
42
            $manager->persist($role);
43
            $this->roles[] = $role;
44
        }
45
46
        $manager->flush();
47
    }
48
49
    /**
50
     * @return Role[]
51
     */
52
    public function getRoles()
53
    {
54
        return $this->roles;
55
    }
56
57
    /**
58
     * @return Role
59
     */
60
    public function getParent()
61
    {
62
        return $this->parent;
63
    }
64
}
65