Total Complexity | 6 |
Total Lines | 78 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | class ResourceAI |
||
21 | { |
||
22 | /** @var string role */ |
||
23 | protected $role = null; |
||
24 | |||
25 | /** @var int user-ID */ |
||
26 | protected $userId = null; |
||
27 | |||
28 | /** @var ForumsUserInterface User to check against */ |
||
29 | protected $user = null; |
||
30 | |||
31 | /** |
||
32 | * Get the user which requests the permission |
||
33 | * |
||
34 | * @return ForumsUserInterface|null |
||
35 | */ |
||
36 | public function getUser(): ?ForumsUserInterface |
||
37 | { |
||
38 | return $this->user; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Get owner-ID of the resource |
||
43 | * |
||
44 | * @return int|null |
||
45 | */ |
||
46 | public function getOwner(): ?int |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get owner of the resource |
||
53 | * |
||
54 | * @return string|null |
||
55 | */ |
||
56 | public function getRole(): ?string |
||
57 | { |
||
58 | return $this->role; |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Set a user which requests the permission |
||
63 | * |
||
64 | * @param ForumsUserInterface $user The user. |
||
65 | * @return self |
||
66 | */ |
||
67 | public function asUser(ForumsUserInterface $user): self |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Set owner role |
||
76 | * |
||
77 | * @param string $role Owner's role |
||
78 | * @return self |
||
79 | */ |
||
80 | public function onRole(string $role): self |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Set owner identity |
||
89 | * |
||
90 | * @param int $userId Owner's user-ID |
||
91 | * @return self |
||
92 | */ |
||
93 | public function onOwner(int $userId): self |
||
100 |