MCPcopy Create free account
hub / github.com/denho/faved / __invoke

Method __invoke

controllers/UserGetController.php:17–41  ·  view source on GitHub ↗
(array $input)

Source from the content-addressed store, hash-verified

15class UserGetController implements ControllerInterface
16{
17 public function __invoke(array $input): ResponseInterface
18 {
19 // Check if authentication is enabled (any user exists)
20 $repository = ServiceContainer::get(Repository::class);
21 $auth_enabled = $repository->userTableNotEmpty();
22
23 if (!$auth_enabled) {
24 return data([
25 'message' => 'User has not been created.',
26 'data' => [
27 'user' => null,
28 ],
29 ], 200);
30 }
31
32 $user = getLoggedInUser();
33
34 if (!$user) {
35 throw new UnauthorizedException('No user is currently logged in.');
36 }
37
38 return success('User retrieved successfully.', [
39 'user' => buildPublicUserObject($user)
40 ]);
41 }
42}

Callers

nothing calls this directly

Calls 6

dataFunction · 0.85
getLoggedInUserFunction · 0.85
buildPublicUserObjectFunction · 0.85
getMethod · 0.80
userTableNotEmptyMethod · 0.80
successFunction · 0.50

Tested by

no test coverage detected