PHP Class Psecio\Jwt\Header

Show file Open project: psecio/jwt

Public Methods

Method Description
__construct ( string $key, string $algorithm = 'HS256', string $type = 'JWT' ) Intitialize the Header
__toString ( ) : string Convert the object to a JSON string
getAlgorithm ( boolean $resolve = false ) : string Get the current algorithm setting If "resolve" is set to true, it finds the value from the types array and returns that
getKey ( ) : string Get the currently set key
getType ( ) : string Return the current type
setAlgorithm ( string $algorithm ) : Header Set the algorithm type
setKey ( string $key ) : Header Set the current object's key value
setType ( string $type ) : Header Set the header type
toArray ( ) : array Convert the object into an array of data

Method Details

__construct() public method

Intitialize the Header
public __construct ( string $key, string $algorithm = 'HS256', string $type = 'JWT' )
$key string Key to use for encoding
$algorithm string Algorithm to use [optional]
$type string Type of object [optional]

__toString() public method

Convert the object to a JSON string
public __toString ( ) : string
return string JSON formatted string

getAlgorithm() public method

Get the current algorithm setting If "resolve" is set to true, it finds the value from the types array and returns that
public getAlgorithm ( boolean $resolve = false ) : string
$resolve boolean Resolve the algorithm to its type
return string Algorithm setting (or resolved value)

getKey() public method

Get the currently set key
public getKey ( ) : string
return string Current key string

getType() public method

Return the current type
public getType ( ) : string
return string Current type setting

setAlgorithm() public method

Set the algorithm type
public setAlgorithm ( string $algorithm ) : Header
$algorithm string Algorithm type
return Header instance

setKey() public method

Set the current object's key value
public setKey ( string $key ) : Header
$key string Key to use for encoding
return Header instance

setType() public method

Set the header type
public setType ( string $type ) : Header
$type string Header type
return Header instance

toArray() public method

Convert the object into an array of data
public toArray ( ) : array
return array Object data as an array