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