Token/SplitToken.php
final public static function fromString(string $token): self
    {
        if (Binary::safeStrlen($token) < self::TOKEN_CHAR_LENGTH) {
            // Don't zero memory as the value is invalid.
            throw new \RuntimeException('Invalid token provided.');
        }

        $instance = new static();
        $instance->token = new HiddenString($token);
        $instance->selector = Binary::safeSubstr($token, 0, 32);
        $instance->verifier = Binary::safeSubstr($token, 32);

        // Don't (re)generate as this needs the salt of the stored hash.
        $instance->verifierHash = null;

        \sodium_memzero($token);

        return $instance;
    }
final public static function fromString(string $token): self
    {
        if (Binary::safeStrlen($token) < self::TOKEN_CHAR_LENGTH) {
            // Don't zero memory as the value is invalid.
            throw new \RuntimeException('Invalid token provided.');
        }

        $instance = new static();
        $instance->token = new HiddenString($token);
        $instance->selector = Binary::safeSubstr($token, 0, 32);
        $instance->verifier = Binary::safeSubstr($token, 32);

        // Don't (re)generate as this needs the salt of the stored hash.
        $instance->verifierHash = null;

        \sodium_memzero($token);

        return $instance;
    }
final public static function fromString ( string $ token ) : self { if ( Binary :: safeStrlen ( $ token ) < self :: TOKEN_CHAR_LENGTH ) { // Don't zero memory as the value is invalid. throw new \ RuntimeException ( 'Invalid token provided.' ) ; } $ instance = new static ( ) ; $ instance -> token = new HiddenString ( $ token ) ; $ instance -> selector = Binary :: safeSubstr ( $ token , 0 , 32 ) ; $ instance -> verifier = Binary :: safeSubstr ( $ token , 32 ) ; // Don't (re)generate as this needs the salt of the stored hash. $ instance -> verifierHash = null ; \ sodium_memzero ( $ token ) ; return $ instance ; }
Recreates a SplitToken object from a string.

Note: The $token is zeroed from memory when valid.

@param string $token

@return static
Recreates a SplitToken object from a string .