UserRole::getRoleId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Potievdev\SlimRbac\Models\Entity;
4
5
use DateTime;
6
use Doctrine\ORM\Mapping as ORM;
7
8
/**
9
 * UserRole
10
 *
11
 * @ORM\Table(
12
 *     name="user_role",
13
 *     uniqueConstraints={@ORM\UniqueConstraint(name="idx_user_role_unique", columns={"user_id", "role_id"})},
14
 *     indexes={@ORM\Index(name="fk_user_role_role", columns={"role_id"})}
15
 *     )
16
 * @ORM\Entity(repositoryClass="Potievdev\SlimRbac\Models\Repository\UserRoleRepository")
17
 * @ORM\HasLifecycleCallbacks
18
 */
19
class UserRole
20
{
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="id", type="integer", nullable=false)
25
     * @ORM\Id
26
     * @ORM\GeneratedValue(strategy="IDENTITY")
27
     */
28
    private $id;
29
30
    /**
31
     * @var integer
32
     *
33
     * @ORM\Column(name="user_id", type="string", nullable=false)
34
     */
35
    private $userId;
36
37
    /**
38
     * @var integer
39
     *
40
     * @ORM\Column(name="role_id", type="integer", nullable=false)
41
     */
42
    private $roleId;
43
44
    /**
45
     * @var DateTime
46
     *
47
     * @ORM\Column(name="created_at", type="datetime", nullable=false)
48
     */
49
    private $createdAt;
50
51
    /**
52
     * @var Role
53
     *
54
     * @ORM\ManyToOne(targetEntity="Potievdev\SlimRbac\Models\Entity\Role")
55
     * @ORM\JoinColumns({
56
     *   @ORM\JoinColumn(name="role_id", referencedColumnName="id")
57
     * })
58
     */
59
    private $role;
60
61
    public function getId(): int
62
    {
63
        return $this->id;
64
    }
65
66
    public function setId(int $id)
67
    {
68
        $this->id = $id;
69
    }
70
71
    public function getUserId(): string
72
    {
73
        return $this->userId;
74
    }
75
76
    public function setUserId(string $userId)
77
    {
78
        $this->userId = $userId;
0 ignored issues
show
Documentation Bug introduced by
The property $userId was declared of type integer, but $userId is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
79
    }
80
81
    public function getRoleId(): int
82
    {
83
        return $this->roleId;
84
    }
85
86
    public function setRoleId(int $roleId)
87
    {
88
        $this->roleId = $roleId;
89
    }
90
91
    public function getCreatedAt(): DateTime
92
    {
93
        return $this->createdAt;
94
    }
95
96
    public function setCreatedAt(DateTime $createdAt)
97
    {
98
        $this->createdAt = $createdAt;
99
    }
100
101
    public function getRole(): Role
102
    {
103
        return $this->role;
104
    }
105
106
    public function setRole(Role $role)
107
    {
108
        $this->role = $role;
109
    }
110
111
    /** @ORM\PrePersist */
112
    public function prePersist()
113
    {
114
        $this->createdAt = new DateTime();
115
    }
116
}
117