ManagesItemsInterface
interface ManagesItemsInterface
API Methods for managing items
See src/Traits/ManagesItemsTrait.php for implementation example
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
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()
Get the collection of items as JSON.
When manager instance is used as a string, return json of items
Details
at line line 20
$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 29
$this
hydrate($data, bool $append = false)
Hydrate with external data, optionally append
at line line 41
$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 51
$this
set(string $alias, null $item = null)
Updates an item
at line line 61
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 71
mixed
get(string $alias, string $fallback = '_michaels_no_fallback')
Get a single item
at line line 78
NoItemFoundMessage
getIfExists($alias)
Return an item if it exist
at line line 87
NoItemFoundMessage
getIfHas($alias)
Return an item if it exist Alias of getIfExists()
at line line 94
array
getAll()
Return all items as array
at line line 101
array
all()
Return all items as array Alias of getAll()
at line line 109
bool
exists($alias)
Confirm or deny that an item exists
at line line 118
bool
has($alias)
Confirm or deny that an item exists Alias of exists()
at line line 124
boolean
isEmpty()
Confirm that manager has no items
at line line 132
$this
remove($alias)
Deletes an item
at line line 138
$this
clear()
Clear the manager
at line line 147
mixed
reset(array $items)
Reset the manager with an array of items Alias of initManager()
at line line 155
string
toJson(int $options)
Get the collection of items as JSON.
at line line 161
string
__toString()
When manager instance is used as a string, return json of items