authenticator = $authenticator; return $this; } /** * @return Authenticator */ public function getAuthenticator() { if ($this->authenticator instanceof Authenticator) { return $this->authenticator; } if (null === $this->authenticator && $this instanceof \Pimple && $this->offsetExists('authentication')) { $this->authenticator = function () { return $this['authentication']; }; } if (null === $this->authenticator) { throw new \LogicException(Authenticator::class . ' instance or locator was not set'); } $instance = call_user_func($this->authenticator); if (!$instance instanceof Authenticator) { throw new \LogicException(sprintf( 'Expects locator to return instance of "%s", got "%s"', Authenticator::class, is_object($instance) ? get_class($instance) : gettype($instance) )); } $this->authenticator = $instance; return $this->authenticator; } /** * @return User|null */ public function getAuthenticatedUser() { return $this->getAuthenticator()->getUser(); } }