for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Http\Message\Authentication;
use Http\Message\Authentication;
use Psr\Http\Message\RequestInterface;
/**
* Authenticate a PSR-7 Request using a token.
*
* @author Márk Sági-Kazár <[email protected]>
*/
final class Bearer implements Authentication
{
* @var string
private $token;
* @param string $token
public function __construct($token)
$this->token = $token;
}
* Returns the token.
* @return string
public function getToken()
return $this->token;
* Sets the token.
public function setToken($token)
* {@inheritdoc}
public function authenticate(RequestInterface $request)
$header = sprintf('Bearer %s', $this->token);
return $request->withHeader('Authorization', $header);