| Total Complexity | 3 |
| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Coverage | 77.78% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class BasicAuthMiddleware implements MiddlewareInterface |
||
| 11 | { |
||
| 12 | private $username; |
||
| 13 | private $password; |
||
| 14 | |||
| 15 | 1 | public function __construct(string $username, string $password) |
|
| 16 | { |
||
| 17 | 1 | $this->username = $username; |
|
| 18 | 1 | $this->password = $password; |
|
| 19 | 1 | } |
|
| 20 | |||
| 21 | 1 | public function handleRequest(RequestInterface $request, callable $next) |
|
| 22 | { |
||
| 23 | 1 | $request = $request->withAddedHeader('Authorization', sprintf('Basic %s', base64_encode($this->username.':'.$this->password))); |
|
| 24 | |||
| 25 | 1 | return $next($request); |
|
| 26 | } |
||
| 27 | |||
| 28 | public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next) |
||
| 31 | } |
||
| 32 | } |
||
| 33 |