PHP Class GenTux\Jwt\JwtToken

Inheritance: implements JsonSerializabl\JsonSerializable
Afficher le fichier Open project: generationtux/jwt-artisan Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( GenTux\Jwt\Drivers\JwtDriverInterface $jwt, string | null $secret = null, string | null $algorithm = null )
__toString ( ) : string Convert into string
algorithm ( ) : string Get the algorithm to use
createToken ( GenTux\Jwt\JwtPayloadInterface | array $payload, string | null $secret = null, string | null $algo = null ) : JwtToken Create a new token with the provided payload
jsonSerialize ( ) : mixed Specify data which should be serialized to JSON
payload ( string | null $path = null, string | null $secret = null, string | null $algo = null ) : array Get the payload from the current token
secret ( ) : string Get the secret to use for token operations
setAlgorithm ( string $algo ) : self Set the algorithm to use
setSecret ( string $secret ) : self Set the secret to use for token operations
setToken ( string $token ) : self Set the current JWT token
token ( ) : string Get the current JWT token
validate ( string | null $secret = null, string | null $algo = null ) : boolean Validate a token
validateOrFail ( string | null $secret = null, string | null $algo = null ) : boolean Validate the token or throw an exception

Private Methods

Méthode Description
queryPayload ( array $payload, string | null $path = null ) : mixed Query the payload using dot syntax to find specific data

Method Details

__construct() public méthode

public __construct ( GenTux\Jwt\Drivers\JwtDriverInterface $jwt, string | null $secret = null, string | null $algorithm = null )
$jwt GenTux\Jwt\Drivers\JwtDriverInterface
$secret string | null
$algorithm string | null

__toString() public méthode

Convert into string
public __toString ( ) : string
Résultat string

algorithm() public méthode

This can be customized by setting the env variable JWT_ALGO
public algorithm ( ) : string
Résultat string

createToken() public méthode

The default algorithm used is HS256. To set a custom one, set the env variable JWT_ALGO.
public createToken ( GenTux\Jwt\JwtPayloadInterface | array $payload, string | null $secret = null, string | null $algo = null ) : JwtToken
$payload GenTux\Jwt\JwtPayloadInterface | array
$secret string | null
$algo string | null
Résultat JwtToken

jsonSerialize() public méthode

Specify data which should be serialized to JSON
public jsonSerialize ( ) : mixed
Résultat mixed data which can be serialized by json_encode, which is a value of any type other than a resource.

payload() public méthode

Get the payload from the current token
public payload ( string | null $path = null, string | null $secret = null, string | null $algo = null ) : array
$path string | null dot syntax to query for specific data
$secret string | null
$algo string | null
Résultat array

secret() public méthode

Get the secret to use for token operations
public secret ( ) : string
Résultat string

setAlgorithm() public méthode

Set the algorithm to use
public setAlgorithm ( string $algo ) : self
$algo string
Résultat self

setSecret() public méthode

Set the secret to use for token operations
public setSecret ( string $secret ) : self
$secret string
Résultat self

setToken() public méthode

Set the current JWT token
public setToken ( string $token ) : self
$token string
Résultat self

token() public méthode

Get the current JWT token
public token ( ) : string
Résultat string

validate() public méthode

Validate a token
public validate ( string | null $secret = null, string | null $algo = null ) : boolean
$secret string | null
$algo string | null
Résultat boolean

validateOrFail() public méthode

Validate the token or throw an exception
public validateOrFail ( string | null $secret = null, string | null $algo = null ) : boolean
$secret string | null
$algo string | null
Résultat boolean