Fast Forward Container API

ServiceFactory implements FactoryInterface

FinalYes

This factory wraps a predefined service instance and returns it directly upon invocation.

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.

Table of Contents

Interfaces

FactoryInterface
Defines a contract for service factories that rely on a PSR-11 container for instantiation.

Methods

__construct()  : mixed
Constructs the factory with a fixed service instance.
__invoke()  : mixed
Returns the fixed service instance.

Methods

__construct()

Constructs the factory with a fixed service instance.

public __construct(mixed $service) : mixed
Parameters
$service : mixed

the service instance to be returned by the factory

__invoke()

Returns the fixed service instance.

public __invoke(ContainerInterface $container) : mixed
Parameters
$container : ContainerInterface

the container instance (ignored in this context)

Return values
mixed

the predefined service instance


        
On this page

Search results