ManagesItemsTrait
trait ManagesItemsTrait
Manages complex, nested data
Methods
Initializes a new manager instance.
Hydrate with external data, optionally append
Adds a single item.
Updates an item
Push a value or values onto the end of an array inside manager
Get a single item
Get a single item
Return an item if it exist
Return an item if it exist Alias of getIfExists()
Return all items as array
Return all items as array Alias of getAll()
Confirm or deny that an item exists
Confirm or deny that an item exists Alias of exists()
Confirm that manager has no items
Deletes an item
Clear the manager
Reset the manager with an array of items Alias of initManager()
Guard an alias from being modified
Merge a set of defaults with the current items
Returns the name of the property that holds data items
Sets the name of the property that holds data items
Get the collection of items as JSON.
When manager instance is used as a string, return json of items
Details
at line line 44
$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()
at line line 72
$this
hydrate($data, bool $append = false)
Hydrate with external data, optionally append
at line line 93
$this
add(string $alias, mixed $item = null, array $options = null)
Adds a single item.
Allow for dot notation (one.two.three) and item nesting.
at line line 155
$this
set(string $alias, null $item = null)
Updates an item
at line line 168
int
push(string $alias, mixed $value, null|mixed $other = null)
Push a value or values onto the end of an array inside manager
at line line 201
mixed
get(string $alias, string $fallback = '_michaels_no_fallback')
Get a single item
Note: When editing, update ManagesIocTrait::getRaw()
at line line 214
mixed
getRaw(string $alias, string $fallback = '_michaels_no_fallback')
Get a single item
at line line 235
NoItemFoundMessage
getIfExists($alias)
Return an item if it exist
at line line 256
NoItemFoundMessage
getIfHas($alias)
Return an item if it exist Alias of getIfExists()
at line line 266
array
getAll()
Return all items as array
at line line 277
array
all()
Return all items as array Alias of getAll()
at line line 288
bool
exists($alias)
Confirm or deny that an item exists
at line line 309
bool
has($alias)
Confirm or deny that an item exists Alias of exists()
at line line 319
boolean
isEmpty()
Confirm that manager has no items
at line line 331
$this
remove($alias)
Deletes an item
at line line 352
$this
clear()
Clear the manager
at line line 366
mixed
reset(array $items)
Reset the manager with an array of items Alias of initManager()
at line line 376
$this
protect($item)
Guard an alias from being modified
at line line 387
$this
loadDefaults(array $defaults)
Merge a set of defaults with the current items
at line line 397
string
getItemsName()
Returns the name of the property that holds data items
at line line 407
$this
setItemsName($nameOfItemsRepository)
Sets the name of the property that holds data items
at line line 419
string
toJson(int $options)
Get the collection of items as JSON.
at line line 428
string
__toString()
When manager instance is used as a string, return json of items