BasicCredentials
A class that represents a pair of user ID and password.
Table of Contents
- __construct() : mixed
- Constructor.
- getCredentials() : string
- Get the credentials in "userid:password" format which is suitable as a parameter part of Basic Authentication.
- getPassword() : string
- Get the password.
- getUserId() : string
- Get the user ID.
- parse() : BasicCredentials
- Create a BasicCredentials instance from the given string whose format is expected to be "Basic {base64-encoded-string}".
Methods
__construct()
Constructor.
public
__construct(string $userId, string $password) : mixed
Parameters
- $userId : string
-
User ID.
- $password : string
-
Password.
Return values
mixed —getCredentials()
Get the credentials in "userid:password" format which is suitable as a parameter part of Basic Authentication.
public
getCredentials() : string
Return values
string —Credentials in "userid:password" format.
getPassword()
Get the password.
public
getPassword() : string
Return values
string —Password.
getUserId()
Get the user ID.
public
getUserId() : string
Return values
string —User ID.
parse()
Create a BasicCredentials instance from the given string whose format is expected to be "Basic {base64-encoded-string}".
public
static parse(string $authorizationHeaderValue) : BasicCredentials
If the given string is null
or it does not match the pattern,
a BasicCredentials
instance whose user ID and password are
both null
is returned.
Parameters
- $authorizationHeaderValue : string
-
A value of
Authorization
header whose scheme isBasic
.
Return values
BasicCredentials —A BasicCredentials
instance generated based on the
information of the given string.