Download the PHP package setnemo/asterisk-notation without Composer
On this page you can find all versions of the php package setnemo/asterisk-notation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setnemo/asterisk-notation
More information about setnemo/asterisk-notation
Files in setnemo/asterisk-notation
Package asterisk-notation
Short Description Asterisk notation for array access in PHP
License MIT
Informations about the package asterisk-notation
PHP Asterisk Notation
Asterisk notation for array access in PHP. Update array access to the next level of usability.
Asterisk notation
Install
Install the latest version using Composer:
Usage
Create a new \Setnemo\Asterisk object:
Methods
Asterisk has the following methods:
- add()
- all()
- clear()
- count()
- delete()
- flatten()
- get()
- has()
- isEmpty()
- merge()
- mergeRecursive()
- mergeRecursiveDistinct()
- pull()
- push()
- replace() // use Dot::replace(), need write tests, because used get(), set()
- set()
- setArray()
- setReference()
- toJson() // use Dot::toJson(), need write tests, because used get()
add()
Using for adding element with asterisk in key
Work like Adbar\Dot::add()
all()
Work like Adbar\Dot::all()
clear()
Deletes the contents of a given key (sets an empty array):
Multiple keys:
All the stored items:
If key not contains * (asterisk) - it works like Adbar\Dot::clear()
count()
Returns the number of items in a given key:
Items in the root of Dot object:
If key not contains * (asterisk) - it works like Adbar\Dot::count()
delete()
Deletes the given key:
Multiple keys:
flatten()
It works like Adbar\Dot::flatten()
get()
Returns the value of a given key:
Returns a given default value, if the given key doesn't exist:
Default value not work with asterisk
has()
Checks if a given key exists (returns boolean true or false):
Multiple keys:
With asterisk:
With asterisk and value:
With asterisk and value (non-strict mode):
isEmpty()
Checks if a given key is empty (returns boolean true or false):
Multiple keys:
Checks the whole Asterisk object:
Also works with asterisk in key:
merge()
It works like Adbar\Dot::merge() Asterisk in path Asterisk::merge('key', 'value') work like Asterisk::set('key', 'value', false)
mergeRecursive()
It works like Adbar\Dot::mergeRecursive() Asterisk in path Asterisk::mergeRecursive('key', 'value') work like Asterisk::set('key', 'value', false)
mergeRecursiveDistinct()
It works like Adbar\Dot::mergeRecursiveDistinct()
pull()
Returns the value of a given key and deletes the key:
Returns a given default value, if the given key doesn't exist:
Default value not work with asterisk in query!
Returns all the stored items as an array and clears the Dot object:
Key with asterisk:
push()
Pushes a given value to the end of the array in a given key:
Pushes a given value to the end of the array:
With asterisk:
Also work as Asterisk::set('key', 'value', true), where true is asterisk boolean. See Asterisk::set()
replace()
It works like Adbar\Dot::replace()
set()
Sets a given key / value pair:
Multiple key / value pairs:
setArray()
It works like Adbar\Dot::setarray()
setReference()
It works like Adbar\Dot::setreference()
toJson()
It works like Adbar\Dot::toJson()
License
MIT license