\Piko\Di\ObjectFactory

Instantiate a class and resolve its constructor dependencies from a PSR-11 container (autowiring). Dependencies typed with a class/interface are fetched from the container; built-in typed parameters fall back to overrides, default values or null.

Methods summary

Name Description
public __construct Constructor
public create Create an object and resolve its constructor depen…

Methods

public __construct(): mixed

public  __construct(\Psr\Container\ContainerInterface  $container): mixed

Parameters

$container :

Return:

mixed


public create(): object

public  create(string  $class, array  $overrides = []): object

Create an object and resolve its constructor dependencies.

Parameters

$class : The class to instantiate.

$overrides (default: []): Constructor argument overrides indexed by parameter name.

throws \RuntimeExceptionIf the class does not exist or a mandatory dependency cannot be resolved.

Return:

object