first version
This commit is contained in:
55
kirby/src/Http/Request/Auth/BearerAuth.php
Executable file
55
kirby/src/Http/Request/Auth/BearerAuth.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Kirby\Http\Request\Auth;
|
||||
|
||||
/**
|
||||
* Bearer Auth
|
||||
*/
|
||||
class BearerAuth
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* Creates a new Bearer Auth object
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
public function __construct(string $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the object to a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return ucfirst($this->type()) . ' ' . $this->token();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authentication token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function token(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the auth type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function type(): string
|
||||
{
|
||||
return 'bearer';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user