Oihana PHP System

helpers

Table of Contents

Functions

getBodyParam()  : mixed
Retrieves a single parameter from the HTTP request body.
getBodyParams()  : array<string|int, mixed>
Retrieves multiple parameters from the HTTP request body.
getController()  : Controller|null
Retrieves a controller instance from a PSR-11 container if available.
getParam()  : mixed
Retrieves a parameter from the HTTP request, supporting query string, body, or both.
getParamArray()  : array<string|int, mixed>|null
Retrieves a parameter from the HTTP request and ensures it is an array.
getParamBool()  : bool|null
Retrieves a parameter from the HTTP request and ensures it is a boolean.
getParamFloat()  : float|null
Retrieves a parameter from the HTTP request and ensures it is a float number.
getParamFloatRange()  : float|null
Retrieves a float parameter from the request and clamps it within a given range.
getParamInt()  : int|null
Retrieves a parameter from the HTTP request and ensures it is a int number.
getParamIntRange()  : int|null
Retrieves an integer parameter from the request and clamps it within a given range.
getParamNumberRange()  : int|float|null
Retrieves a numeric parameter from the request and clamps it within a given range.
getParamString()  : string|null
Retrieves a parameter from the HTTP request and ensures it is a string.
getQueryParam()  : mixed
Retrieves a single parameter from the HTTP request query string.
getDocumentsModel()  : DocumentsModel|null
Resolves a {@see DocumentsModel} instance from a PSR-11 container or returns a default.
getModel()  : Model|null
Resolves a model instance from a PSR-11 container or returns a default.
resolveDependency()  : mixed
Resolves a dependency definition from a PSR-11 container or returns a default value.

Functions

getBodyParam()

Retrieves a single parameter from the HTTP request body.

getBodyParam(ServerRequestInterface|null $request, string $name) : mixed

This helper extracts a value from the parsed request body ($request->getParsedBody()), supporting dot notation for nested structures (e.g. 'user.address.city').

The body is internally normalized into a fully associative array using toAssociativeArray(), ensuring compatibility with both array and stdClass-based JSON payloads.

It internally uses hasKeyValue() and getKeyValue() from the oihana\core\accessors namespace.

If the request is null, or if the specified parameter does not exist, the function returns null.

Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or nested key path (e.g. 'geo.latitude').

Tags
example

Retrieve a flat parameter:

// POST body: ['name' => 'Alice']
echo getBodyParam($request, 'name'); // 'Alice'

Retrieve a nested parameter using dot notation:

// POST body: ['geo' => ['latitude' => 42.5, 'longitude' => 1.5]]
echo getBodyParam($request, 'geo.latitude'); // '42.5'

Handle missing keys or null request:

echo getBodyParam(null, 'foo');            // null
echo getBodyParam($request, 'not.exists'); // null
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
mixed

The parameter value if found, or null otherwise.

getBodyParams()

Retrieves multiple parameters from the HTTP request body.

getBodyParams(ServerRequestInterface|null $request[, array<string|int, mixed> $names = [] ]) : array<string|int, mixed>

This helper extracts one or more values from the parsed request body ($request->getParsedBody()), supporting dot notation for nested structures (e.g. 'user.address.city').

Each requested key from $names is resolved recursively via hasKeyValue() and getKeyValue(), and reassembled into a new associative array using setKeyValue(). The request body is first normalized into a pure associative array using toAssociativeArray(), ensuring compatibility with both array and stdClass payloads.

If the request is null, the function returns null. If none of the requested keys exist, an empty array is returned.

Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance. If null, no extraction is performed.

$names : array<string|int, mixed> = []

A list of parameter names (keys or dot-notated paths) to extract.

Tags
example

Retrieve multiple flat parameters:

// POST body: ['name' => 'Alice', 'age' => 30]
$params = getBodyParams($request, ['name', 'age']);
// ['name' => 'Alice', 'age' => 30]

Retrieve nested parameters with dot notation:

// POST body: ['user' => ['profile' => ['email' => 'a@b.c', 'active' => true]]]
$params = getBodyParams($request, ['user.profile.email', 'user.profile.active']);
// ['user' => ['profile' => ['email' => 'a@b.c', 'active' => true]]]

Handle missing keys or null request:

getBodyParams(null, ['foo', 'bar']);  // []
getBodyParams($request, ['unknown']); // []
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
array<string|int, mixed>

An associative array of extracted values. Nested keys are preserved according to dot notation.

getController()

Retrieves a controller instance from a PSR-11 container if available.

getController([array<string|int, mixed>|string|null|Controller $definition = null ][, ContainerInterface|null $container = null ][, Controller|null $default = null ]) : Controller|null

This function attempts to fetch a controller by its identifier ($id) from the given container. If the container is provided and contains the specified entry, it is resolved and returned if it is an instance of Controller. Otherwise, the optional $default controller is returned.

Parameters
$definition : array<string|int, mixed>|string|null|Controller = null

The controller definition within the container.

$container : ContainerInterface|null = null

The PSR-11 container to fetch the controller from (optional).

$default : Controller|null = null

A fallback controller to return if the container does not provide one (optional).

Tags
throws
ContainerExceptionInterface

If an error occurs while retrieving the controller from the container.

throws
NotFoundExceptionInterface

If the controller identifier does not exist in the container.

Return values
Controller|null

The resolved controller instance or the provided default value, or null if none found.

getParam()

Retrieves a parameter from the HTTP request, supporting query string, body, or both.

getParam(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $default = [] ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : mixed

This helper searches for the requested parameter $name in the request according to the specified $strategy:

  • HttpParamStrategy::QUERY → only query string parameters.
  • HttpParamStrategy::BODY → only parsed body parameters.
  • HttpParamStrategy::BOTH → query string first, then body.

Nested keys are supported via dot notation (e.g., 'user.profile.email'). Body parameters are normalized to an associative array using toAssociativeArray().

If the parameter is not found:

  • Returns the corresponding value in $default[$name] if present.
  • Returns null if no default is provided.
  • Throws DI\NotFoundException if $throwable is true.
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$default : array<string|int, mixed> = []

Optional default values as an associative array.

$strategy : string = HttpParamStrategy::BOTH

One of HttpParamStrategy::QUERY|BODY|BOTH. Default: BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default: false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

author

Marc Alcaraz (ekameleon)

since
1.0.0
example
// Query parameter only
$request = ...; // ?name=Alice
getParam($request, 'name', [], HttpParamStrategy::QUERY);

// Body parameter only
$request = ...; // ['user' => ['email' => 'a@b.c']]
getParam($request, 'user.email', [], HttpParamStrategy::BODY);

// Both sources, with fallback
getParam($request, 'foo', ['foo' => 'default'], HttpParamStrategy::BOTH);

// Throw exception if missing
getParam($request, 'bar', [], HttpParamStrategy::BOTH, true);
Return values
mixed

The parameter value if found, otherwise the default value or null.

getParamArray()

Retrieves a parameter from the HTTP request and ensures it is an array.

getParamArray(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, array<string|int, mixed>|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : array<string|int, mixed>|null

This helper calls getParam() and checks the returned value:

  • If the value is an array, it is returned.
  • Otherwise, the $defaultValue is returned.
  • If $throwable is true, a NotFoundException may be thrown by getParam().
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$args : array<string|int, mixed> = []

Optional default values passed to getParam().

$defaultValue : array<string|int, mixed>|null = null

Value returned if the parameter is missing or not an array. Default is null.

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query string: ?filters[status]=active&filters[roles][]=admin
$filters = getParamArray($request, 'filters', [], ['status' => 'all']);
example
// Body: ['user' => ['roles' => ['editor', 'admin']]]
$roles = getParamArray($request, 'user.roles', [], []);
example
// Non-array value, returns default
$tags = getParamArray($request, 'tags', [], ['default']);
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
array<string|int, mixed>|null

The parameter value if it is an array, otherwise $defaultValue or null.

getParamBool()

Retrieves a parameter from the HTTP request and ensures it is a boolean.

getParamBool(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, bool|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : bool|null

This helper calls getParam() and interprets the value according to Boolean::TRUE and Boolean::FALSE:

  • If the value matches Boolean::TRUE or Boolean::FALSE, it is converted to a PHP boolean.
  • Otherwise, the $defaultValue is returned.
  • If $throwable is true, a NotFoundException may be thrown by getParam().
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$args : array<string|int, mixed> = []

Optional default values passed to getParam().

$defaultValue : bool|null = null

Value returned if the parameter is missing or not a boolean. Default is null.

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query string: ?active=true
$active = getParamBool($request, 'active', [], false);

// Body: ['enabled' => Boolean::FALSE]
$enabled = getParamBool($request, 'enabled', [], true);
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
bool|null

The parameter value if it is a boolean, otherwise $defaultValue or null.

getParamFloat()

Retrieves a parameter from the HTTP request and ensures it is a float number.

getParamFloat(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, float|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : float|null

This helper calls getParam() and converts the returned value to a float if set.

  • If the value is null or missing, the $defaultValue is returned.
  • If $throwable is true, a NotFoundException may be thrown by getParam().
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$args : array<string|int, mixed> = []

Optional default values passed to getParam().

$defaultValue : float|null = null

Value returned if the parameter is missing or not set. Default is null.

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query string: ?price=19.95
$price = getParamFloat($request, 'price', [], 0.0); // 19.95

// Body: ['discount' => '5.5']
$discount = getParamFloat($request, 'discount', [], null); // 5.5

// Missing parameter, uses default
$tax = getParamFloat($request, 'tax', [], 1.0); // 1.0
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
float|null

The parameter value cast to float if present, otherwise $defaultValue or null.

getParamFloatRange()

Retrieves a float parameter from the request and clamps it within a given range.

getParamFloatRange(ServerRequestInterface|null $request, string $name, float $min, float $max[, float|null $defaultValue = null ][, array<string|int, mixed> $args = [] ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : float|null

Wrapper around getParamNumberRange() that ensures float return type.

Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance. Can be null.

$name : string

The parameter name or dot-notated path.

$min : float

Minimum allowed float value.

$max : float

Maximum allowed float value.

$defaultValue : float|null = null

Value returned if the parameter is missing or not numeric. Default null.

$args : array<string|int, mixed> = []

Optional defaults passed to getParam().

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default BOTH.

$throwable : bool = false

Whether to throw NotFoundException if the parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found in the request.

throws
NotFoundException
example
$discount = getParamFloatRange($request, 'discount', 0.0, 100.0, 0.0);
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
float|null

The float value clamped to [$min, $max], or $defaultValue/null if missing or invalid.

getParamInt()

Retrieves a parameter from the HTTP request and ensures it is a int number.

getParamInt(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, int|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : int|null

This helper calls getParam() and converts the returned value to a int if set.

  • If the value is null or missing, the $defaultValue is returned.
  • If $throwable is true, a NotFoundException may be thrown by getParam().
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$args : array<string|int, mixed> = []

Optional default values passed to getParam().

$defaultValue : int|null = null

Value returned if the parameter is missing or not set. Default is null.

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query string: ?age=19
$price = getParamInt($request, 'age', [], 0); // 19

// Body: ['age' => '5']
$discount = getParamInt($request, 'age', [], null); // 5

// Missing parameter, uses default
$tax = getParamInt($request, 'age', [], 1); // 1
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|null

The parameter value cast to int if present, otherwise $defaultValue or null.

getParamIntRange()

Retrieves an integer parameter from the request and clamps it within a given range.

getParamIntRange(ServerRequestInterface|null $request, string $name, int $min, int $max[, int|null $defaultValue = null ][, array<string|int, mixed> $args = [] ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : int|null

Wrapper around getParamNumberRange() that ensures integer return type.

Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance. Can be null.

$name : string

The parameter name or dot-notated path.

$min : int

Minimum allowed integer value.

$max : int

Maximum allowed integer value.

$defaultValue : int|null = null

Value returned if the parameter is missing or not numeric. Default null.

$args : array<string|int, mixed> = []

Optional defaults passed to getParam().

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default BOTH.

$throwable : bool = false

Whether to throw NotFoundException if the parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found in the request.

example
$quantity = getParamIntRange($request, 'quantity', 1, 10, 5);
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|null

The integer value clamped to [$min, $max], or $defaultValue/null if missing or invalid.

getParamNumberRange()

Retrieves a numeric parameter from the request and clamps it within a given range.

getParamNumberRange(ServerRequestInterface|null $request, string $name, int|float $min, int|float $max[, int|float|null $defaultValue = null ][, array<string|int, mixed> $args = [] ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : int|float|null

This helper calls getParam() and:

  • Converts the value to int or float.
  • Returns $defaultValue if the parameter is missing or not numeric.
  • Clamps the value between $min and $max.
  • Can throw NotFoundException if $throwable is true and parameter is missing.
Parameters
$request : ServerRequestInterface|null

The PSR-7 request instance.

$name : string

Parameter name or dot-notated path.

$min : int|float

Minimum allowed value.

$max : int|float

Maximum allowed value.

$defaultValue : int|float|null = null

Value returned if missing or invalid. Default null.

$args : array<string|int, mixed> = []

Optional defaults passed to getParam().

$strategy : string = HttpParamStrategy::BOTH

Source to search: BOTH, QUERY, BODY. Default BOTH.

$throwable : bool = false

Whether to throw NotFoundException if missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query: ?price=15
$price = getParamNumberRange($request, 'price', 0, 100, 10); // 15

// Body: ['discount' => 150]
$discount = getParamNumberRange($request, 'discount', 0, 100, 0); // 100 (clamped)

// Missing value
$tax = getParamNumberRange($request, 'tax', 0, 50, 5); // 5 (default)
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
int|float|null

The numeric value clamped to the range [$min, $max], or $defaultValue/null if missing or invalid.

getParamString()

Retrieves a parameter from the HTTP request and ensures it is a string.

getParamString(ServerRequestInterface|null $request, string $name[, array<string|int, mixed> $args = [] ][, string|null $defaultValue = null ][, string $strategy = HttpParamStrategy::BOTH ][, bool $throwable = false ]) : string|null

This helper calls getParam() and converts the returned value to a string if set.

  • If the value is null or missing, the $defaultValue is returned.
  • If $throwable is true, a NotFoundException may be thrown by getParam().
Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance.

$name : string

The parameter name or dot-notated path.

$args : array<string|int, mixed> = []

Optional default values passed to getParam().

$defaultValue : string|null = null

Value returned if the parameter is missing or null. Default is null.

$strategy : string = HttpParamStrategy::BOTH

Which source to search: HttpParamStrategy::BOTH|QUERY|BODY. Default is BOTH.

$throwable : bool = false

Whether to throw a NotFoundException if parameter is missing. Default false.

Tags
throws
NotFoundException

If $throwable is true and the parameter is not found.

example
// Query string: ?name=Alice
$name = getParamString($request, 'name'); // "Alice"

// Body: ['title' => 'Manager']
$title = getParamString($request, 'title', [], 'Default'); // "Manager"

// Missing parameter, uses default
$nickname = getParamString($request, 'nickname', [], 'Guest'); // "Guest"
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string|null

The parameter value cast to string if present, otherwise $defaultValue or null.

getQueryParam()

Retrieves a single parameter from the HTTP request query string.

getQueryParam(ServerRequestInterface|null $request, string $name) : mixed

This helper extracts a value from the query parameters ($request->getQueryParams()), supporting dot notation for nested structures (e.g. 'filter.page').

It internally uses hasKeyValue() and getKeyValue() from the oihana\core\accessors namespace.

If the request is null, or if the specified parameter does not exist, the function returns null.

Parameters
$request : ServerRequestInterface|null

The PSR-7 server request instance. If null, no extraction is performed.

$name : string

The query parameter name or nested key path (e.g. 'filter.page').

Tags
example

Retrieve a flat parameter:

// URL: /api/users?name=Alice&age=30
echo getQueryParam($request, 'name'); // 'Alice'
echo getQueryParam($request, 'age');  // '30'

Retrieve a nested parameter using dot notation:

// URL: /api/users?filter[page]=2&filter[limit]=10
echo getQueryParam($request, 'filter.page');  // '2'
echo getQueryParam($request, 'filter.limit'); // '10'

Handle missing keys or null request:

getQueryParam(null, 'foo');            // null
getQueryParam($request, 'not.exists'); // null
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
mixed

The parameter value if found, or null otherwise.

getDocumentsModel()

Resolves a {@see DocumentsModel} instance from a PSR-11 container or returns a default.

getDocumentsModel([string|DocumentsModel|null $definition = null ][, ContainerInterface|null $container = null ][, DocumentsModel|null $default = null ]) : DocumentsModel|null

This helper function provides a flexible way to obtain a DocumentsModel instance:

  • If $definition is already a DocumentsModel, it is returned as-is.
  • If $definition is a string and $container implements ContainerInterface, the function attempts to resolve the corresponding service from the container.
  • If resolution fails, the provided $default (if any) is returned instead.

This pattern allows for safe dependency resolution in controllers or services, without requiring explicit type-checking or container awareness in user code.

Parameters
$definition : string|DocumentsModel|null = null

The model definition — either:

  • a DocumentsModel instance (returned directly),
  • a string service identifier (resolved from $container),
  • or null (uses $default).
$container : ContainerInterface|null = null

Optional PSR-11 container to resolve string identifiers.

$default : DocumentsModel|null = null

Optional fallback model if no valid instance is found.

Tags
throws
ContainerExceptionInterface

If the container encounters an internal error.

throws
NotFoundExceptionInterface

If $definition is a string not found in the container.

example
use oihana\controllers\helpers\getDocumentsModel;
use oihana\models\interfaces\DocumentsModel;
use Psr\Container\ContainerInterface;

// Case 1: Direct instance
$model = new MyDocumentsModel();
echo getDocumentsModel( $model ) === $model ? 'ok' : 'fail' ; // ok

// Case 2: String identifier resolved via container
$container = new Container(); // implements ContainerInterface
$container->set( 'mainModel', new MyDocumentsModel() );

$resolved = getDocumentsModel( 'mainModel', $container );
echo $resolved instanceof DocumentsModel ? 'ok' : 'fail' ;   // ok

// Case 3: Fallback to default model
$default = new DefaultDocumentsModel();
echo getDocumentsModel( 'unknown', $container, $default ) === $default ? 'ok' : 'fail' ; // ok
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
DocumentsModel|null

The resolved model, the provided default, or null if none.

getModel()

Resolves a model instance from a PSR-11 container or returns a default.

getModel([array<string|int, mixed>|string|Model|null $definition = null ][, ContainerInterface|null $container = null ][, Model|null $default = null ]) : Model|null

This function attempts to retrieve a Model instance based on the provided definition. The definition can be:

  • A Model instance (returned directly),
  • An array containing a ModelParam::MODEL key,
  • A string identifier for a model in a PSR-11 container.
Parameters
$definition : array<string|int, mixed>|string|Model|null = null

The model definition, which can be:

  • a Model instance,
  • an array with key ModelParam::MODEL,
  • a string identifier in the container,
  • or null.
$container : ContainerInterface|null = null

Optional PSR-11 container used to resolve a string definition.

$default : Model|null = null

Optional fallback model returned if none could be resolved.

Tags
throws
ContainerExceptionInterface

If an error occurs while retrieving the model from the container.

throws
NotFoundExceptionInterface

If a string definition is provided but not found in the container.

author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
Model|null

The resolved Model instance, the provided default, or null if none found.

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
throws
ContainerExceptionInterface

If an error occurs while retrieving the dependency from the container.

throws
NotFoundExceptionInterface

If a string definition is provided but not found in the container.

example
$logger = resolveDependency(LoggerInterface::class, $container, new NullLogger());
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
mixed

Returns the resolved dependency from the container, or $default if not found.


        
On this page

Search results