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
ContainerNotFoundException
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
 forKey
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/config.
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/config
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Config\Exception;
20
21use Exception;
22use Psr\Container\NotFoundExceptionInterface;
23
24/**
25 * Class ContainerNotFoundException.
26 *
27 * Exception thrown when a configuration key is not found in the container.
28 * This class MUST implement the PSR-11 NotFoundExceptionInterface.
29 */
30 class ContainerNotFoundException extends Exception implements NotFoundExceptionInterface
31{
32    /**
33     * Creates a new exception instance for a missing configuration key.
34     *
35     * This factory method SHOULD be used when a key lookup fails in the ConfigContainer.
36     *
37     * @param string $key the key that was not found
38     *
39     * @return self a new instance of the exception describing the missing key
40     */
41    public static function forKey(string $key): self
42    {
43        return new self(\sprintf('Config key "%s" not found.', $key));
44    }
45}