Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 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\Factory; |
| 20 | |
| 21 | use Psr\Container\ContainerInterface; |
| 22 | |
| 23 | /** |
| 24 | * Defines a contract for service factories that rely on a PSR-11 container for instantiation. |
| 25 | * |
| 26 | * Implementing classes MUST implement the __invoke method which SHALL be responsible for returning |
| 27 | * the fully constructed service instance. |
| 28 | * |
| 29 | * This interface is commonly used in container-based systems to register factories dynamically. |
| 30 | */ |
| 31 | interface FactoryInterface |
| 32 | { |
| 33 | /** |
| 34 | * Creates a service instance using the provided container. |
| 35 | * |
| 36 | * Implementations MUST resolve all necessary dependencies from the container |
| 37 | * and return a fully constructed instance. |
| 38 | * |
| 39 | * @param ContainerInterface $container the PSR-11 compliant container providing dependencies |
| 40 | * |
| 41 | * @return mixed the created service instance |
| 42 | */ |
| 43 | public function __invoke(ContainerInterface $container): mixed; |
| 44 | } |