Repository navigation
MethodFactory
A factory that invokes a public method on a class or a container-provided object.
This factory MUST be used when service creation requires calling a non-constructor method, and supports both static and instance methods.
If the method is not public, a RuntimeException SHALL be thrown.
Arguments MAY be resolved from the container if passed as service identifiers.
- Full name:
\FastForward\Container\Factory\MethodFactory - 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 MethodFactory.
public __construct(string $class, string $method, mixed $arguments): mixedParameters:
| Parameter | Type | Description |
|---|---|---|
$class |
string | the class name or container service ID on which the method is called |
$method |
string | the name of the method to invoke |
$arguments |
mixed | Optional arguments to pass to the method. |
Resolves the class and invokes the configured method with arguments.
public __invoke(\Psr\Container\ContainerInterface $container): mixedArguments MAY be resolved from the container if passed as string identifiers and found. Public static class methods are invoked without resolving an instance. Instance targets are retrieved by class name or service ID and reflected using the resolved object. Direct construction is permitted only when has() reports a class-name entry as absent. Failures resolving registered targets propagate, including missing nested dependencies.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$container |
\Psr\Container\ContainerInterface | The container used to resolve the class and arguments |
Return Value:
The result of invoking the method
Throws:
If the method does not exist
-
ReflectionExceptionIf the method is not public -
RuntimeExceptionif a non-class service ID is absent NotFoundExceptionInterface