Total Complexity | 2 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class HttpBearer extends HttpHeader |
||
16 | { |
||
17 | protected string $headerName = Header::AUTHORIZATION; |
||
18 | |||
19 | /** |
||
20 | * @psalm-var non-empty-string |
||
21 | */ |
||
22 | protected string $pattern = '/^Bearer\s+(.*?)$/'; |
||
23 | |||
24 | private string $realm = 'api'; |
||
25 | |||
26 | 3 | public function challenge(ResponseInterface $response): ResponseInterface |
|
27 | { |
||
28 | 3 | return $response->withHeader(Header::WWW_AUTHENTICATE, "{$this->headerName} realm=\"{$this->realm}\""); |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param string $realm The HTTP authentication realm. |
||
33 | */ |
||
34 | 2 | public function withRealm(string $realm): self |
|
39 | } |
||
40 | } |
||
41 |