Bolt\AccessControl\Token\Generator::__construct PHP Method

__construct() public method

Constructor.
public __construct ( string $username, string $salt, string $remoteIP, string $hostName, string $userAgent, array $cookieOptions, string $algorithm = 'sha256' )
$username string
$salt string
$remoteIP string
$hostName string
$userAgent string
$cookieOptions array
$algorithm string
    public function __construct($username, $salt, $remoteIP, $hostName, $userAgent, array $cookieOptions, $algorithm = 'sha256')
    {
        if ($remoteIP === null) {
            throw new \InvalidArgumentException('Token generator requires an IP address to be provided');
        }
        if ($hostName === null) {
            throw new \InvalidArgumentException('Token generator requires a remote host name to be provided');
        }
        if ($userAgent === null) {
            throw new \InvalidArgumentException('Token generator requires a browser user agent to be provided');
        }
        $remoteIP = $cookieOptions['remoteaddr'] ? $remoteIP : '';
        $hostName = $cookieOptions['browseragent'] ? $userAgent : '';
        $userAgent = $cookieOptions['httphost'] ? $hostName : '';
        $this->token = hash($algorithm, $username . $salt . $remoteIP . $hostName . $userAgent);
    }