class UberManager implements ManagesItemsInterface, ChainsNestedItemsInterface, IocManagerInterface, LoadsFilesInterface, ArrayAccess, Countable, IteratorAggregate, JsonSerializable, ContainerInterface

Manages deeply nested, complex data.

This manager class does it all, and is more a proof of concept than anything else. It manages dependencies, loads files, uses magic methods, is arrayable, and all the rest.

Traits

Manages complex, nested data
Access Deeply nested manager items through magic methods
Class ArrayableTrait
Manages complex, nested data
Loads data from configuration-type files into Manager

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, mixed $item = null)

Adds a single item.

$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 $fallback = '_michaels_no_fallback')

Get a single item

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()

$this
protect($item)

Guard an alias from being modified

$this
loadDefaults(array $defaults)

Merge a set of defaults with the current items

string
getItemsName()

Returns the name of the property that holds data items

$this
setItemsName($nameOfItemsRepository)

Sets the name of the property that holds data items

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
drop()

Deletes item at the current level of nesting (and below)

$this
__get(string $name)

Sets the current level of nesting.

mixed
__call(string $name, array $arguments)

Retrieves a value from the manager at the current nest level.

$this
__set(string $key, mixed $value)

Sets an item at the current nest level.

bool
offsetExists($offset)

No description

mixed
offsetGet($offset)

No description

offsetSet($offset, $value)

No description

offsetUnset($offset)

No description

getIterator()

No description

count()

No description

array
jsonSerialize()

No description

$this
initDi(array $components = array())

Initializes IoC Container

getIocManifest()

Returns the entire IoC Manifest

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

Returns the request object with all dependencies

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

Adds a dependency to the manager

mixed
share($alias)

Turns a dependency into a singleton.

$this
setup($alias, $pipeline)

Add a pipeline to to the que

string
getDiItemsName()

Returns the name of the property that holds data items

$this
setDiItemsName($nameOfItemsRepository)

Sets the name of the property that holds data items

void
loadFiles(array $files, $append = false, bool $namespace = true)

This method adds the file loading functionality.

loadFile($file, $append = false, $namespace = true)

No description

mixed
addDecoder(DecoderInterface $decoder)

Allows for the addition of a custom decoder to the manager load files system.

getFileLoader()

No description

setFileLoader(FileLoader $fileLoader)

No description

__construct(array $items = array())

Build a new manager instance

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

in DependsOnManagesItemsTrait at line line 35
abstract $this add(string $alias, mixed $item = null)

Adds a single item.

Allow for dot notation (one.two.three) and item nesting.

Parameters

string $alias Key to be stored
mixed $item Value to be stored

Return Value

$this

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

Updates an item

Parameters

string $alias
null $item

Return Value

$this

in DependsOnManagesItemsTrait at line line 55
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

in DependsOnManagesItemsTrait at line line 65
abstract mixed get(string $alias, string $fallback = '_michaels_no_fallback')

Get a single item

Parameters

string $alias
string $fallback Defaults to 'michaelsno_fallback' so null can be a fallback

Return Value

mixed

Exceptions

ItemNotFoundException If item not found

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

Return an item if it exist

Parameters

$alias

Return Value

NoItemFoundMessage

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

Return an item if it exist Alias of getIfExists()

Parameters

$alias

Return Value

NoItemFoundMessage

in DependsOnManagesItemsTrait at line line 88
abstract array getAll()

Return all items as array

Return Value

array

in DependsOnManagesItemsTrait at line line 95
abstract array all()

Return all items as array Alias of getAll()

Return Value

array

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

Confirm or deny that an item exists

Parameters

$alias

Return Value

bool

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

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

Parameters

$alias

Return Value

bool

in DependsOnManagesItemsTrait at line line 118
abstract boolean isEmpty()

Confirm that manager has no items

Return Value

boolean

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

Deletes an item

Parameters

$alias

Return Value

$this

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

Clear the manager

Return Value

$this

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

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

Parameters

array $items

Return Value

mixed

in ManagesItemsTrait at line line 350
$this protect($item)

Guard an alias from being modified

Parameters

$item

Return Value

$this

in ManagesItemsTrait at line line 361
$this loadDefaults(array $defaults)

Merge a set of defaults with the current items

Parameters

array $defaults

Return Value

$this

in ManagesItemsTrait at line line 371
string getItemsName()

Returns the name of the property that holds data items

Return Value

string

in ManagesItemsTrait at line line 381
$this setItemsName($nameOfItemsRepository)

Sets the name of the property that holds data items

Parameters

$nameOfItemsRepository

Return Value

$this

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

Get the collection of items as JSON.

Parameters

int $options

Return Value

string

in DependsOnManagesItemsTrait at line line 155
abstract string __toString()

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

Return Value

string

in ChainsNestedItemsTrait at line line 26
mixed drop()

Deletes item at the current level of nesting (and below)

Return Value

mixed

in ChainsNestedItemsTrait at line line 39
$this __get(string $name)

Sets the current level of nesting.

Parameters

string $name Next level in dot notation to set

Return Value

$this

See also

Michaels\Manager\Contracts\ChainsNestedItemsInterface

in ChainsNestedItemsTrait at line line 55
mixed __call(string $name, array $arguments)

Retrieves a value from the manager at the current nest level.

Parameters

string $name The alias to be retrieved
array $arguments Not used at present

Return Value

mixed item value

Exceptions

ItemNotFoundException

See also

Michaels\Manager\Contracts\ChainsNestedItemsInterface

in ChainsNestedItemsTrait at line line 68
$this __set(string $key, mixed $value)

Sets an item at the current nest level.

Parameters

string $key The alias to be retrieved
mixed $value Value to be set

Return Value

$this

See also

Michaels\Manager\Contracts\ChainsNestedItemsInterface

in ArrayableTrait at line line 19
bool offsetExists($offset)

Parameters

$offset

Return Value

bool

in ArrayableTrait at line line 29
mixed offsetGet($offset)

Parameters

$offset

Return Value

mixed

in ArrayableTrait at line line 39
offsetSet($offset, $value)

Parameters

$offset
$value

in ArrayableTrait at line line 48
offsetUnset($offset)

Parameters

$offset

in ArrayableTrait at line line 56
getIterator()

in ArrayableTrait at line line 64
count()

in ArrayableTrait at line line 73
array jsonSerialize()

Return Value

array

in ManagesIocTrait at line line 26
$this initDi(array $components = array())

Initializes IoC Container

Parameters

array $components

Return Value

$this

in ManagesIocTrait at line line 38
array|NoItemFoundMessage getIocManifest()

Returns the entire IoC Manifest

Return Value

array|NoItemFoundMessage

in ManagesIocTrait at line line 57
mixed fetch(string $alias, string|mixed $fallback = '_michaels_no_fallback')

Returns the request object with all dependencies

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 ManagesIocTrait at line line 98
$this di(string $alias, callable|string|object $factory, 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 ManagesIocTrait at line line 129
mixed share($alias)

Turns a dependency into a singleton.

Parameters

$alias

Return Value

mixed

in ManagesIocTrait at line line 141
$this setup($alias, $pipeline)

Add a pipeline to to the que

Parameters

$alias
$pipeline

Return Value

$this

in ManagesIocTrait at line line 151
string getDiItemsName()

Returns the name of the property that holds data items

Return Value

string

in ManagesIocTrait at line line 161
$this setDiItemsName($nameOfItemsRepository)

Sets the name of the property that holds data items

Parameters

$nameOfItemsRepository

Return Value

$this

in LoadsFilesTrait at line line 44
void loadFiles(array $files, $append = false, bool $namespace = true)

This method adds the file loading functionality.

Parameters

array $files an array of SplFileInfo Objects
$append boolean true, if data should be appended to the manager.
bool $namespace

Return Value

void

in LoadsFilesTrait at line line 52
loadFile($file, $append = false, $namespace = true)

Parameters

$file
$append
$namespace

in LoadsFilesTrait at line line 63
mixed addDecoder(DecoderInterface $decoder)

Allows for the addition of a custom decoder to the manager load files system.

Parameters

DecoderInterface $decoder

Return Value

mixed

in LoadsFilesTrait at line line 72
FileLoader getFileLoader()

Return Value

FileLoader

in LoadsFilesTrait at line line 80
setFileLoader(FileLoader $fileLoader)

Parameters

FileLoader $fileLoader

at line line 48
__construct(array $items = array())

Build a new manager instance

Parameters

array $items