Skip to content

Latest commit

 

History

History
108 lines (74 loc) · 2.19 KB

Functions.md

File metadata and controls

108 lines (74 loc) · 2.19 KB

Atanvarno\Dependency functions

entry()

Helper for referencing a container entry in a definition.

function entry(string $id): Entry

Parameters

  • string $id

    Required. Container entry identifier to reference.

Throws

Nothing is thrown.

Returns

  • Entry

    A reference to the container entry.

factory()

Helper for defining a container entry using a factory function/callable.

function factory(callable $callable, array $parameters = [], bool $register = true): Definition

Parameters

  • callable $callable

    Required. A callable that returns the desired value.

  • array $parameters

    Optional. Defaults to []. A list of parameters to pass to the given callable.

  • bool $register

    Optional. Defaults to true. Whether the entry returned should be registered by the container.

Throws

Nothing is thrown.

Returns

object()

Helper for defining an object container entry.

function object(string $className, array $parameters = [], bool $register = true): Definition

Parameters

  • string $className

    Required. The class name of the object to define. Use of the ::class constant is recommended.

  • array $parameters

    Optional. Defaults to []. A list of parameters to pass to the given class's constructor.

  • bool $register

    Optional. Defaults to true. Whether the entry returned should be registered by the container.

Throws

Nothing is thrown.

Returns

value()

Helper for defining a generic value container entry.

function value($value, bool $register = true): Definition

Parameters

  • mixed $value

    Required. The value the container should return.

  • bool $register

    Optional. Defaults to true. Whether the value returned should be registered by the container.

Throws

Nothing is thrown.

Returns