Conditions | 4 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.1755 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
25 | 16 | public function getUser(): LoggedInUser |
|
26 | { |
||
27 | 16 | $user = $this->security->getUser(); |
|
28 | 16 | if ($user == null) { |
|
29 | throw new \RuntimeException("You are not logged in!"); |
||
30 | } |
||
31 | 16 | if ($user instanceof LoggedInUser) { |
|
32 | 13 | return $user; |
|
33 | } |
||
34 | 3 | if ($user instanceof User) { |
|
35 | 3 | return new LoggedInUser($user->getId(), $user->getUserIdentifier(), $user->getRoles()); |
|
36 | } |
||
37 | throw new \RuntimeException("Unsupported User Class: " . $user::class); |
||
38 | } |
||
39 | } |