Total Complexity | 7 |
Total Lines | 69 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
23 | final class Guest implements IUser { |
||
24 | |||
25 | |||
26 | /** |
||
27 | * @brief This implementation returns always `null`. |
||
28 | * @return null |
||
29 | */ |
||
30 | public function getId() { |
||
31 | return NULL; |
||
32 | } |
||
33 | |||
34 | |||
35 | /** |
||
36 | * @brief This implementation returns always `false`. |
||
37 | * @param[in] string $id The id to match. |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function match($id) { |
||
41 | return FALSE; |
||
42 | } |
||
43 | |||
44 | |||
45 | /** |
||
46 | * @copydoc IUser::has() |
||
47 | */ |
||
48 | public function has(IPermission $permission) { |
||
49 | $role = new GuestRole(); |
||
50 | |||
51 | $permissionReflection = new \ReflectionObject($permission); |
||
52 | |||
53 | if ($permissionReflection->hasMethod('checkForGuestRole')) { // If a method exists for the roleName... |
||
54 | // Gets the method. |
||
55 | $method = $permissionReflection->getMethod('checkForGuestRole'); |
||
56 | |||
57 | $permission->setRole($role); |
||
58 | |||
59 | // Invokes the method. |
||
60 | return $method->invoke($permission); |
||
61 | } |
||
62 | else |
||
63 | return FALSE; |
||
64 | } |
||
65 | |||
66 | |||
67 | /** |
||
68 | * @brief This implementation returns always `true`. |
||
69 | * @return bool |
||
70 | */ |
||
71 | public function isGuest() { |
||
72 | return TRUE; |
||
73 | } |
||
74 | |||
75 | |||
76 | /** |
||
77 | * @brief This implementation returns always `false`. |
||
78 | * @return bool |
||
79 | */ |
||
80 | public function isMember() { |
||
82 | } |
||
83 | |||
84 | |||
85 | /** |
||
86 | * @brief This method is never called for this class, but in case it will return an empty collection. |
||
87 | * @return RoleCollection |
||
88 | */ |
||
89 | public function getRoles() { |
||
92 | } |
||
93 | |||
94 | } |