trait ManagesIocTrait

Manages complex, nested data

Traits

Methods

$this
initManager(array $items = null)

Initializes a new manager instance.

$this
hydrate($data, bool $append = false)

Hydrate with external data, optionally append

$this
add(string $alias, callable|string|object $factory = null, array $declared = null)

Adds a dependency to the manager

$this
set(string $alias, null $item = null)

Updates an item

int
push(string $alias, mixed $value, null|mixed $other = null)

Push a value or values onto the end of an array inside manager

mixed
get(string $alias, string|mixed $fallback = '_michaels_no_fallback')

Returns the request object with all dependencies

NoItemFoundMessage
getIfExists($alias)

Return an item if it exist

NoItemFoundMessage
getIfHas($alias)

Return an item if it exist Alias of getIfExists()

array
getAll()

Return all items as array

array
all()

Return all items as array Alias of getAll()

bool
exists($alias)

Confirm or deny that an item exists

bool
has($alias)

Confirm or deny that an item exists Alias of exists()

boolean
isEmpty()

Confirm that manager has no items

$this
remove($alias)

Deletes an item

$this
clear()

Clear the manager

mixed
reset(array $items)

Reset the manager with an array of items Alias of initManager()

string
toJson(int $options)

Get the collection of items as JSON.

string
__toString()

When manager instance is used as a string, return json of items

mixed
fetch(string $alias, string|mixed $fallback = '_michaels_no_fallback')

Alias of get() for backwards comparability

mixed
share($alias)

Turns a dependency into a singleton.

$this
setup($alias, $pipeline)

Add a pipeline to to the que

Details

in DependsOnManagesItemsTrait at line line 15
abstract $this initManager(array $items = null)

Initializes a new manager instance.

This is useful for implementations that have their own __construct method This is an alias for reset()

Parameters

array $items

Return Value

$this

in DependsOnManagesItemsTrait at line line 24
abstract $this hydrate($data, bool $append = false)

Hydrate with external data, optionally append

Parameters

$data string The data to be hydrated into the manager
bool $append When true, data will be appended to the current set

Return Value

$this

at line line 87
$this add(string $alias, callable|string|object $factory = null, array $declared = null)

Adds a dependency to the manager

$factory can be a: string Full class name for a new object each time callable Factory to create new object (passed manager) object The exact object to be returned

Parameters

string $alias
callable|string|object $factory
array $declared

Return Value

$this

in DependsOnManagesItemsTrait at line line 46
abstract $this set(string $alias, null $item = null)

Updates an item

Parameters

string $alias
null $item

Return Value

$this

in DependsOnManagesItemsTrait at line line 56
abstract int push(string $alias, mixed $value, null|mixed $other = null)

Push a value or values onto the end of an array inside manager

Parameters

string $alias The level of nested data
mixed $value The first value to append
null|mixed $other Optional other values to apend

Return Value

int Number of items pushed

Exceptions

ItemNotFoundException If pushing to unset array

at line line 33
mixed get(string $alias, string|mixed $fallback = '_michaels_no_fallback')

Returns the request object with all dependencies

Overrides the get() method on ManagesItemsTrait Use getRaw() to return the raw value

string Full class name for a new object each time callable Factory to create new object (passed manager) object The exact object to be returned

Parameters

string $alias
string|mixed $fallback

Return Value

mixed

Exceptions

Exception

in DependsOnManagesItemsTrait at line line 73
abstract NoItemFoundMessage getIfExists($alias)

Return an item if it exist

Parameters

$alias

Return Value

NoItemFoundMessage

in DependsOnManagesItemsTrait at line line 82
abstract NoItemFoundMessage getIfHas($alias)

Return an item if it exist Alias of getIfExists()

Parameters

$alias

Return Value

NoItemFoundMessage

in DependsOnManagesItemsTrait at line line 89
abstract array getAll()

Return all items as array

Return Value

array

in DependsOnManagesItemsTrait at line line 96
abstract array all()

Return all items as array Alias of getAll()

Return Value

array

in DependsOnManagesItemsTrait at line line 104
abstract bool exists($alias)

Confirm or deny that an item exists

Parameters

$alias

Return Value

bool

in DependsOnManagesItemsTrait at line line 113
abstract bool has($alias)

Confirm or deny that an item exists Alias of exists()

Parameters

$alias

Return Value

bool

in DependsOnManagesItemsTrait at line line 119
abstract boolean isEmpty()

Confirm that manager has no items

Return Value

boolean

in DependsOnManagesItemsTrait at line line 127
abstract $this remove($alias)

Deletes an item

Parameters

$alias

Return Value

$this

in DependsOnManagesItemsTrait at line line 133
abstract $this clear()

Clear the manager

Return Value

$this

in DependsOnManagesItemsTrait at line line 142
abstract mixed reset(array $items)

Reset the manager with an array of items Alias of initManager()

Parameters

array $items

Return Value

mixed

in DependsOnManagesItemsTrait at line line 150
abstract string toJson(int $options)

Get the collection of items as JSON.

Parameters

int $options

Return Value

string

in DependsOnManagesItemsTrait at line line 156
abstract string __toString()

When manager instance is used as a string, return json of items

Return Value

string

at line line 69
mixed fetch(string $alias, string|mixed $fallback = '_michaels_no_fallback')

Alias of get() for backwards comparability

Parameters

string $alias
string|mixed $fallback

Return Value

mixed

Exceptions

Exception

at line line 118
mixed share($alias)

Turns a dependency into a singleton.

Parameters

$alias

Return Value

mixed

at line line 130
$this setup($alias, $pipeline)

Add a pipeline to to the que

Parameters

$alias
$pipeline

Return Value

$this