Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ContainerNotFoundException | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| forKey | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(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 | * @link https://github.com/php-fast-forward/config |
| 12 | * @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <github@mentordosnerds.com> |
| 13 | * @license https://opensource.org/licenses/MIT MIT License |
| 14 | */ |
| 15 | |
| 16 | namespace FastForward\Config\Exception; |
| 17 | |
| 18 | use Psr\Container\NotFoundExceptionInterface; |
| 19 | |
| 20 | /** |
| 21 | * Class ContainerNotFoundException. |
| 22 | * |
| 23 | * Exception thrown when a configuration key is not found in the container. |
| 24 | * This class MUST implement the PSR-11 NotFoundExceptionInterface. |
| 25 | */ |
| 26 | final class ContainerNotFoundException extends \Exception implements NotFoundExceptionInterface |
| 27 | { |
| 28 | /** |
| 29 | * Creates a new exception instance for a missing configuration key. |
| 30 | * |
| 31 | * This factory method SHOULD be used when a key lookup fails in the ConfigContainer. |
| 32 | * |
| 33 | * @param string $key the key that was not found |
| 34 | * |
| 35 | * @return self a new instance of the exception describing the missing key |
| 36 | */ |
| 37 | public static function forKey(string $key): self |
| 38 | { |
| 39 | return new self(\sprintf('Config key "%s" not found.', $key)); |
| 40 | } |
| 41 | } |