0 follower

Final Class Yiisoft\Csrf\StubCsrfToken

InheritanceYiisoft\Csrf\StubCsrfToken
ImplementsYiisoft\Csrf\CsrfTokenInterface

StubCsrfToken represents a simple implementation of CsrfTokenInterface.

This implementation simply stores and returns a token string. It does not perform any additional validation. It is primarily used for testing or as a placeholder implementation.

Method Details

Hide inherited methods

__construct() public method

public __construct( string|null $token null ): mixed
$token string|null

                public function __construct(?string $token = null)
{
    if (null === $token) {
        $token = Random::string();
    }
    $this->token = $token;
}

            
getValue() public method

public getValue( ): string

                public function getValue(): string
{
    return $this->token;
}

            
validate() public method

public validate( string $token ): boolean
$token string

                public function validate(string $token): bool
{
    return $this->token === $token;
}