Total Complexity | 2 |
Total Lines | 20 |
Duplicated Lines | 0 % |
Coverage | 50% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | final class HttpBearer extends HttpHeader |
||
13 | { |
||
14 | private const HEADER_NAME = 'Authorization'; |
||
15 | private const PATTERN = '/^Bearer\s+(.*?)$/'; |
||
16 | |||
17 | protected string $headerName = self::HEADER_NAME; |
||
18 | protected string $pattern = self::PATTERN; |
||
19 | /** |
||
20 | * @var string the HTTP authentication realm |
||
21 | */ |
||
22 | private string $realm = 'api'; |
||
23 | |||
24 | 1 | public function challenge(ResponseInterface $response): ResponseInterface |
|
25 | { |
||
26 | 1 | return $response->withHeader('WWW-Authenticate', "{$this->headerName} realm=\"{$this->realm}\""); |
|
27 | } |
||
28 | |||
29 | public function setRealm(string $realm): void |
||
32 | } |
||
33 | } |
||
34 |