\Piko\Di\ComponentContainer

PSR-11 container backed by the application component registry. Components may be registered as ready-made objects or as lazy factories (callables). A callable is invoked on first access, then its result is memoized so that subsequent calls return the same instance (lazy singleton).

The registry is shared by reference with its owner (Piko\Application::$components) so that memoization and external mutations of the registry stay in sync.

Methods summary

Name Description
public __construct Constructor
public get {@inheritDoc}
public has {@inheritDoc}

Methods

public __construct(): mixed

public  __construct((object|callable)[] & $components): mixed

Parameters

$components : The component registry, passed by reference.

Return:

mixed


public get(): mixed

public  get(string  $id): mixed

{@inheritDoc}

Parameters

$id :

throws \Piko\Di\Exception\NotFoundExceptionIf no component is registered under the given id.

throws \Piko\Di\Exception\ContainerExceptionIf a lazy factory does not resolve to an object.

Return:

mixed


public has(): bool

public  has(string  $id): bool

{@inheritDoc}

Parameters

$id :

Return:

bool