PHP Class Lcobucci\JWT\Token

Since: 0.1.0
Author: Luís Otávio Cobucci Oblonczyk ([email protected])
显示文件 Open project: lcobucci/jwt Class Usage Examples

Public Methods

Method Description
__construct ( array $headers = ['alg' => 'none'], array $claims = [], Lcobucci\JWT\Signature $signature = null, array $payload = ['', ''] ) Initializes the object
__toString ( ) : string Returns an encoded representation of the token
getClaim ( string $name, mixed $default = null ) : mixed Returns the value of a token claim
getClaims ( ) : array Returns the token claim set
getHeader ( string $name, mixed $default = null ) : mixed Returns the value of a token header
getHeaders ( ) : array Returns the token headers
getPayload ( ) : string Returns the token payload
hasClaim ( string $name ) : boolean Returns if the claim is configured
hasHeader ( string $name ) : boolean Returns if the header is configured
isExpired ( DateTimeInterfac\DateTimeInterface $now = null ) : boolean Determine if the token is expired.
validate ( ValidationData $data ) : boolean Validates if the token is valid
verify ( Lcobucci\JWT\Signer $signer, Lcobucci\JWT\Signer\Key | string $key ) : boolean Verify if the key matches with the one that created the signature

Private Methods

Method Description
getHeaderValue ( string $name ) : mixed Returns the value stored in header
getValidatableClaims ( ) : Generator Yields the validatable claims

Method Details

__construct() public method

Initializes the object
public __construct ( array $headers = ['alg' => 'none'], array $claims = [], Lcobucci\JWT\Signature $signature = null, array $payload = ['', ''] )
$headers array
$claims array
$signature Lcobucci\JWT\Signature
$payload array

__toString() public method

Returns an encoded representation of the token
public __toString ( ) : string
return string

getClaim() public method

Returns the value of a token claim
public getClaim ( string $name, mixed $default = null ) : mixed
$name string
$default mixed
return mixed

getClaims() public method

Returns the token claim set
public getClaims ( ) : array
return array

getHeader() public method

Returns the value of a token header
public getHeader ( string $name, mixed $default = null ) : mixed
$name string
$default mixed
return mixed

getHeaders() public method

Returns the token headers
public getHeaders ( ) : array
return array

getPayload() public method

Returns the token payload
public getPayload ( ) : string
return string

hasClaim() public method

Returns if the claim is configured
public hasClaim ( string $name ) : boolean
$name string
return boolean

hasHeader() public method

Returns if the header is configured
public hasHeader ( string $name ) : boolean
$name string
return boolean

isExpired() public method

Determine if the token is expired.
public isExpired ( DateTimeInterfac\DateTimeInterface $now = null ) : boolean
$now DateTimeInterfac\DateTimeInterface Defaults to the current time.
return boolean

validate() public method

Validates if the token is valid
public validate ( ValidationData $data ) : boolean
$data ValidationData
return boolean

verify() public method

Verify if the key matches with the one that created the signature
public verify ( Lcobucci\JWT\Signer $signer, Lcobucci\JWT\Signer\Key | string $key ) : boolean
$signer Lcobucci\JWT\Signer
$key Lcobucci\JWT\Signer\Key | string
return boolean