This factory wraps a predefined service instance and returns it directly upon invocation.
Description
It SHALL be used when a fixed service object must be registered in a container using a factory interface.
The returned value MUST be the exact same instance provided at construction.
This ensures immutability and predictable resolution.
Interfaces
Defines a contract for service factories that rely on a PSR-11 container for instantiation.
Properties
Methods
Constructs the factory with a fixed service instance.
Returns the fixed service instance.
Constructs the factory with a fixed service instance.
public
__construct(
mixed
$service) : mixed
Parameters
$service
:
mixed
Description
the service instance to be returned by the factory
Returns the fixed service instance.
public
__invoke(ContainerInterface
$container) : mixed
Parameters
$container
:
ContainerInterface
Description
the container instance (ignored in this context)
Return values
Description
the predefined service instance