/** * Retrieve the current identity, if any. * * If none is present, returns null. * * @return mixed|null * @throws RuntimeException */ public function __invoke() { if (!$this->authenticationService instanceof AuthenticationServiceInterface) { throw new RuntimeException('No AuthenticationService instance provided'); } if (!$this->authenticationService->hasIdentity()) { return null; } return $this->authenticationService->getIdentity(); }