Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
BearerCredential
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/**
6 * This file is part of php-fast-forward/http-message.
7 *
8 * This source file is subject to the license bundled
9 * with this source code in the file LICENSE.
10 *
11 * @copyright Copyright (c) 2025-2026 Felipe SayĆ£o Lobato Abreu <github@mentordosnerds.com>
12 * @license   https://opensource.org/licenses/MIT MIT License
13 *
14 * @see       https://github.com/php-fast-forward/http-message
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Http\Message\Header\Authorization;
20
21use SensitiveParameter;
22
23/**
24 * Class BearerCredential.
25 *
26 * Represents the parsed credential for HTTP Bearer Token Authentication.
27 * Bearer tokens MUST be treated as opaque secrets that grant access to the
28 * associated protected resource. Any party in possession of the token MAY
29 * use it, therefore implementations MUST ensure the token is never exposed
30 * in logs, stack traces, debug output, or error messages.
31 *
32 * This credential SHALL be produced by the Bearer authentication parser in
33 * {@see FastForward\Http\Message\Header\Authorization::parse()} when a valid
34 * Bearer token is provided by the client.
35 */
36final readonly class BearerCredential implements AuthorizationCredential
37{
38    /**
39     * Creates a new Bearer token credential instance.
40     *
41     * The token parameter is marked with `#[\SensitiveParameter]` because it
42     * MUST be handled as a private security secret; leaking its value may
43     * allow unauthorized access to the protected system.
44     *
45     * @param string $token the opaque bearer token provided by the client
46     */
47    public function __construct(
48        #[SensitiveParameter]
49        public string $token,
50    ) {}
51}