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
NotFoundException
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
 forServiceID
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/container.
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/container
15 * @see       https://github.com/php-fast-forward
16 * @see       https://datatracker.ietf.org/doc/html/rfc2119
17 */
18
19namespace FastForward\Container\Exception;
20
21use Exception;
22use Psr\Container\NotFoundExceptionInterface;
23
24/**
25 * Exception thrown when a requested service identifier is not found in the container.
26 *
27 * This class MUST be used in PSR-11 container implementations to represent an error
28 * condition where a service ID does not exist in the container. It implements the
29 * Psr\Container\NotFoundExceptionInterface to guarantee interoperability with PSR-11 consumers.
30 */
31 class NotFoundException extends Exception implements NotFoundExceptionInterface
32{
33    /**
34     * Creates a new NotFoundException for a missing service identifier.
35     *
36     * This factory method SHOULD be used by the container implementation to report
37     * the absence of a given service ID. The resulting exception message SHALL clearly
38     * indicate which identifier was not resolved.
39     *
40     * @param string $id the service identifier that was not found
41     *
42     * @return self an instance of NotFoundException describing the missing service
43     */
44    public static function forServiceID(string $id): self
45    {
46        return new self(\sprintf('Service "%s" not found.', $id));
47    }
48}