Passed
Pull Request — master (#213)
by Kevin
03:16
created

User   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 12
c 1
b 0
f 1
dl 0
loc 48
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setRole() 0 6 2
A getId() 0 3 1
A getRole() 0 3 1
A setName() 0 5 1
A getName() 0 3 1
1
<?php
2
3
namespace Zenstruck\Foundry\Tests\Fixtures\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
/**
8
 * @ORM\Entity
9
 * @ORM\Table(name="users")
10
 */
11
class User
12
{
13
    /**
14
     * @ORM\Id
15
     * @ORM\GeneratedValue
16
     * @ORM\Column(type="integer")
17
     */
18
    private $id;
19
20
    /**
21
     * @ORM\Column(type="string")
22
     */
23
    private $name;
24
25
    /**
26
     * @ORM\OneToOne(targetEntity=Role::class, mappedBy="user")
27
     */
28
    private $role;
29
30
    public function getId(): ?int
31
    {
32
        return $this->id;
33
    }
34
35
    public function getName(): ?string
36
    {
37
        return $this->name;
38
    }
39
40
    public function setName(string $name): self
41
    {
42
        $this->name = $name;
43
44
        return $this;
45
    }
46
47
    public function setRole(Role $role)
48
    {
49
        $this->role = $role;
50
51
        if ($role->getUser() !== $this) {
52
            $role->setUser($this);
53
        }
54
    }
55
56
    public function getRole()
57
    {
58
        return $this->role;
59
    }
60
}
61