Completed
Push — master ( a199f7...eac768 )
by Oleg
06:42
created

History::getChangeAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authorization\Entities;
5
6
use Doctrine\ORM\Mapping as ORM;
7
use SlayerBirden\DataFlowServer\Domain\Entities\ClaimedResourceInterface;
8
use SlayerBirden\DataFlowServer\Domain\Entities\User;
9
10
/**
11
 * @ORM\Entity()
12
 * @ORM\Table(name="permission_history")
13
 */
14
class History implements ClaimedResourceInterface
15
{
16
    /**
17
     * @ORM\Id()
18
     * @ORM\GeneratedValue()
19
     * @ORM\Column(type="integer")
20
     * @var integer
21
     */
22
    private $id;
23
    /**
24
     * User who've made the change.
25
     * @ORM\ManyToOne(targetEntity="\SlayerBirden\DataFlowServer\Domain\Entities\User")
26
     * @ORM\JoinColumn(onDelete="SET NULL")
27
     * @var User
28
     */
29
    private $owner;
30
    /**
31
     * User with permissions
32
     * @ORM\ManyToOne(targetEntity="\SlayerBirden\DataFlowServer\Domain\Entities\User")
33
     * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
34
     * @var User
35
     */
36
    private $user;
37
    /**
38
     * Resource address
39
     * @ORM\Column(type="string", nullable=false)
40
     * @var string
41
     */
42
    private $resource;
43
    /**
44
     * What was done: added/modified/deleted
45
     * @ORM\Column(type="string", nullable=false)
46
     * @var string
47
     */
48
    private $changeAction;
49
    /**
50
     * When was the change made.
51
     * @ORM\Column(type="datetime")
52
     * @var \DateTime
53
     */
54
    private $at;
55
    /**
56
     * Link to existing permission (if still exists)
57
     * @ORM\ManyToOne(targetEntity="\SlayerBirden\DataFlowServer\Authorization\Entities\Permission")
58
     * @ORM\JoinColumn(onDelete="SET NULL")
59
     * @var Permission
60
     */
61
    private $permission;
62
63
    /**
64
     * @return int
65
     */
66 2
    public function getId(): int
67
    {
68 2
        return $this->id;
69
    }
70
71
    /**
72
     * @return User
73
     */
74 2
    public function getOwner(): User
75
    {
76 2
        return $this->owner;
77
    }
78
79
    /**
80
     * @param User $owner
81
     */
82 4
    public function setOwner(User $owner): void
83
    {
84 4
        $this->owner = $owner;
85 4
    }
86
87
    /**
88
     * @return User
89
     */
90 2
    public function getUser(): User
91
    {
92 2
        return $this->user;
93
    }
94
95
    /**
96
     * @param User $user
97
     */
98 4
    public function setUser(User $user): void
99
    {
100 4
        $this->user = $user;
101 4
    }
102
103
    /**
104
     * @return string
105
     */
106 2
    public function getResource(): string
107
    {
108 2
        return $this->resource;
109
    }
110
111
    /**
112
     * @param string $resource
113
     */
114 4
    public function setResource(string $resource): void
115
    {
116 4
        $this->resource = $resource;
117 4
    }
118
119
    /**
120
     * @return string
121
     */
122 2
    public function getChangeAction(): string
123
    {
124 2
        return $this->changeAction;
125
    }
126
127
    /**
128
     * @param string $changeAction
129
     */
130 4
    public function setChangeAction(string $changeAction): void
131
    {
132 4
        $this->changeAction = $changeAction;
133 4
    }
134
135
    /**
136
     * @return \DateTime
137
     */
138 2
    public function getAt(): \DateTime
139
    {
140 2
        return $this->at;
141
    }
142
143
    /**
144
     * @param \DateTime $at
145
     */
146 4
    public function setAt(\DateTime $at): void
147
    {
148 4
        $this->at = $at;
149 4
    }
150
151
    /**
152
     * @return Permission|null
153
     */
154 2
    public function getPermission(): ?Permission
155
    {
156 2
        return $this->permission;
157
    }
158
159
    /**
160
     * @param Permission $permission
161
     */
162 4
    public function setPermission(Permission $permission): void
163
    {
164 4
        $this->permission = $permission;
165 4
    }
166
}
167