Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| InvalidArgumentException | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| forUnsupportedInitializer | |
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/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 | |
| 19 | namespace FastForward\Container\Exception; |
| 20 | |
| 21 | /** |
| 22 | * Exception thrown when an invalid or unsupported argument is passed to a function or method within the container. |
| 23 | * |
| 24 | * This exception helps identify and handle errors related to invalid or unrecognized arguments, |
| 25 | * especially when an unsupported initializer type is provided to the container builder. |
| 26 | */ |
| 27 | class InvalidArgumentException extends \InvalidArgumentException |
| 28 | { |
| 29 | /** |
| 30 | * Creates an exception indicating an unsupported container initializer. |
| 31 | * |
| 32 | * This method SHALL be used to indicate that an unrecognized initializer type |
| 33 | * was passed to the container builder function. |
| 34 | * |
| 35 | * @param mixed $value the value that was identified as unsupported |
| 36 | * |
| 37 | * @return self a new InvalidArgumentException with a descriptive message |
| 38 | */ |
| 39 | public static function forUnsupportedInitializer(mixed $value): self |
| 40 | { |
| 41 | return new self(\sprintf('Unsupported initializer type: %s', get_debug_type($value))); |
| 42 | } |
| 43 | } |