-
Notifications
You must be signed in to change notification settings - Fork 0
InvokableFactory
Factory responsible for instantiating a class with constructor arguments.
This class MUST be used when a service should be created using a known class name and optionally injected with fixed arguments.
It SHALL invoke the constructor directly using the spread operator and provided arguments. This factory is suitable for services that do not require container-based dependency injection.
- Full name:
\FastForward\Container\Factory\InvokableFactory
- This class is marked as final and can't be subclassed
- This class implements:
\FastForward\Container\Factory\FactoryInterface
- This class is a Final class
Constructs the InvokableFactory with a target class and optional constructor arguments.
public __construct(string $class, mixed $arguments): mixed
This constructor MUST receive a valid, instantiable class name. Any variadic arguments provided SHALL be passed to the class constructor during instantiation. If an argument is a string and matches a service ID in the container, it SHALL be resolved from the container.
Parameters:
Parameter | Type | Description |
---|---|---|
$class |
string | the fully qualified class name to be instantiated |
$arguments |
mixed | A variadic list of constructor arguments. |
Creates an instance of the class with the provided arguments.
public __invoke(\Psr\Container\ContainerInterface $container): mixed
Arguments that are strings and match a known service ID in the container SHALL be replaced with the corresponding container-resolved services.
It MUST return a new instance of the class with the resolved arguments. This method SHALL be invoked by the container when the service is requested.
Parameters:
Parameter | Type | Description |
---|---|---|
$container |
\Psr\Container\ContainerInterface | The PSR-11 compliant container providing dependencies |
Return Value:
The created service instance
Throws:
thrown if an error occurs during service instantiation
thrown if a required service ID is not found in the container
Automatically generated on 2025-07-03