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
ApiKeyCredential
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 ApiKeyCredential.
25 *
26 * Represents the credential structure for API Key–based authentication.
27 * Implementations using this credential MUST treat the API key as an opaque
28 * secret. The value MUST NOT be logged, exposed, or transmitted to
29 * unauthorized parties, as possession of the key typically grants full
30 * authorization to the associated account or resource.
31 *
32 * This class SHALL be returned by the {@see Authorization::ApiKey} parser
33 * when the `Authorization` header contains a valid API key value. The key
34 * MAY represent either a static key, a signed token, or any user-defined
35 * string depending on the server's authentication strategy.
36 */
37final readonly class ApiKeyCredential implements AuthorizationCredential
38{
39    /**
40     * Creates a new API Key credential instance.
41     *
42     * The provided key MUST be stored exactly as received and MUST NOT be
43     * modified or normalized internally. Any validation, expiration checks,
44     * or transformation logic MUST be performed by the caller or the
45     * authentication subsystem responsible for interpreting API keys.
46     *
47     * @param string $key the raw API key provided by the client
48     */
49    public function __construct(
50        #[SensitiveParameter]
51        public string $key,
52    ) {}
53}