resolveDependency.php
Table of Contents
Functions
- resolveDependency() : mixed
- Resolves a dependency definition from a PSR-11 container or returns a default value.
Functions
resolveDependency()
Resolves a dependency definition from a PSR-11 container or returns a default value.
resolveDependency(string|null $dependency[, ContainerInterface|null $container = null ][, mixed $default = null ]) : mixed
This function attempts to retrieve a service or object from a PSR-11 container if a string identifier is provided. If the container is null, the dependency is not found, or the input is not a string, the provided default value is returned.
Parameters
- $dependency : string|null
-
The container entry ID to resolve.
- $container : ContainerInterface|null = null
-
Optional PSR-11 container to resolve the dependency from.
- $default : mixed = null
-
Value to return if the dependency cannot be resolved.
Tags
Return values
mixed —Returns the resolved dependency from the container, or $default if not found.