eden / array
Autoloading, error and exception handler
Installs: 388 386
Dependents: 20
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.1
- eden/core: 4.*
README
- Install
- Introduction
- API
- arsort
- asort
- changeKeyCase
- chunk
- combine
- count
- countValues
- diff
- diffAssoc
- diffKey
- diffUassoc
- diffUkey
- fill
- fillKeys
- filter
- flip
- implode
- inArray
- intersect
- intersectAssoc
- intersectKey
- intersectUassoc
- intersectUkey
- keys
- krsort
- ksort
- map
- merge
- mergeRecursive
- natcasesort
- natsort
- pad
- pop
- push
- reverse
- rsort
- search
- shift
- shuffle
- sizeof
- slice
- sort
- splice
- sum
- uasort
- udiff
- udiffAssoc
- udiffUassoc
- uintersect
- uintersectAssoc
- uintersectUassoc
- uksort
- unique
- unshift
- usort
- values
- walk
- walkRecursive
- Contributing
====
Install
composer install eden/array
====
Enable Eden
The following documentation uses eden()
in its example reference. Enabling this function requires an extra step as descirbed in this section which is not required if you access this package using the following.
Eden_Array_Index::i();
When using composer, there is not an easy way to access functions from packages. As a workaround, adding this constant in your code will allow eden()
to be available after.
Eden::DECORATOR;
For example:
Eden::DECORATOR;
eden()->inspect('Hello World');
====
Introduction
Chainable array methods. When using multiple PHP array functions in one line, it makes code harder to read. This is because a programmer needs to be trained to read code from inner to outer, rather than traditionally left to right (unless you live in Japan). Eden's data typing are objects that correct this readability problem.
array_keys(array_reverse(array_flip(array(4, 5, 6)))); // [6, 5, 4]
The above demonstrates that we must read this as array_flip()
, then array_reverse()
, followed by array_keys()
which is inner function first going outwards. The example below shows how using types makes this line easier to read.
echo eden('array')->set(4, 5, 6)->flip()->reverse()->keys(); //--> [6, 5, 4]
When echoed the array object will automatically convert to a readable json. Eden covers most of the array functions provided by PHP. Below is a list of string methods you can linearly perform.
echo eden('array')
->set(4, 5, 6)
->flip()
->reverse()
->keys(); //--> [6, 5, 4]
Expressed vertically as above shows something more pleasing to a developer. Array objects, for the most part, can also be treated as regular arrays as implied below.
//instantiate
$array = eden('array')->set(1, 2, 3);
//push in a new value
$array[] = 4;
echo $array[1]; //--> 2
foreach($array as $key => $value) {} //loop through array
====
API
====
addslashes
Same as PHP: addslashes
Usage
eden('string')->addslashes();
Example
eden('string')->set('Hello')->addslashes();
====
bin2hex
Same as PHP: bin2hex
Usage
eden('string')->bin2hex();
Example
eden('string')->set('Hello')->bin2hex();
====
chunkSplit
Same as PHP: chunk_split
Usage
eden('string')->chunkSplit();
Example
eden('string')->set('Hello')->chunkSplit();
====
convertUudecode
Same as PHP: convert_uudecode
Usage
eden('string')->convertUudecode();
Example
eden('string')->set('Hello')->convertUudecode();
====
convertUuencode
Same as PHP: convert_uuencode
Usage
eden('string')->convertUuencode();
Example
eden('string')->set('Hello')->convertUuencode();
====
countChars
Same as PHP: count_chars
Usage
eden('string')->countChars();
Example
eden('string')->set('Hello')->countChars();
====
crypt
Same as PHP: crypt
Usage
eden('string')->crypt();
Example
eden('string')->set('Hello')->crypt();
====
explode
Same as PHP: explode
Usage
eden('string')->explode();
Example
eden('string')->set('Hello')->explode();
====
hex2bin
Same as PHP: hex2bin
Usage
eden('string')->hex2bin();
Example
eden('string')->set('Hello')->hex2bin();
====
htmlEntityDecode
Same as PHP: html_entity_decode
Usage
eden('string')->htmlEntityDecode();
Example
eden('string')->set('Hello')->htmlEntityDecode();
====
htmlentities
Same as PHP: htmlentities
Usage
eden('string')->htmlentities();
Example
eden('string')->set('Hello')->htmlentities();
====
htmlspecialchars
Same as PHP: htmlspecialchars
Usage
eden('string')->htmlspecialchars();
Example
eden('string')->set('Hello')->htmlspecialchars();
====
htmlspecialcharsDecode
Same as PHP: htmlspecialchars_decode
Usage
eden('string')->htmlspecialcharsDecode();
Example
eden('string')->set('Hello')->htmlspecialcharsDecode();
====
ipTags
Same as PHP: strip_tags
Usage
eden('string')->ipTags();
Example
eden('string')->set('Hello')->ipTags();
====
ipcslashes
Same as PHP: stripcslashes
Usage
eden('string')->ipcslashes();
Example
eden('string')->set('Hello')->ipcslashes();
====
ipslashes
Same as PHP: stripslashes
Usage
eden('string')->ipslashes();
Example
eden('string')->set('Hello')->ipslashes();
====
ireplace
Same as PHP: str_ireplace
Usage
eden('string')->ireplace();
Example
eden('string')->set('Hello')->ireplace();
====
istr
Same as PHP: stristr
Usage
eden('string')->istr();
Example
eden('string')->set('Hello')->istr();
====
lcfirst
Same as PHP: lcfirst
Usage
eden('string')->lcfirst();
Example
eden('string')->set('Hello')->lcfirst();
====
len
Same as PHP: strlen
Usage
eden('string')->len();
Example
eden('string')->set('Hello')->len();
====
ltrim
Same as PHP: ltrim
Usage
eden('string')->ltrim();
Example
eden('string')->set('Hello')->ltrim();
====
md5
Same as PHP: md5
Usage
eden('string')->md5();
Example
eden('string')->set('Hello')->md5();
====
nl2br
Same as PHP: nl2br
Usage
eden('string')->nl2br();
Example
eden('string')->set('Hello')->nl2br();
====
pad
Same as PHP: str_pad
Usage
eden('string')->pad();
Example
eden('string')->set('Hello')->pad();
====
pbrk
Same as PHP: strpbrk
Usage
eden('string')->pbrk();
Example
eden('string')->set('Hello')->pbrk();
====
pos
Same as PHP: strpos
Usage
eden('string')->pos();
Example
eden('string')->set('Hello')->pos();
====
pregReplace
Same as PHP: preg_replace
Usage
eden('string')->pregReplace();
Example
eden('string')->set('Hello')->pregReplace();
====
quotedPrintableDecode
Same as PHP: quoted_printable_decode
Usage
eden('string')->quotedPrintableDecode();
Example
eden('string')->set('Hello')->quotedPrintableDecode();
====
quotedPrintableEncode
Same as PHP: quoted_printable_encode
Usage
eden('string')->quotedPrintableEncode();
Example
eden('string')->set('Hello')->quotedPrintableEncode();
====
quotemeta
Same as PHP: quotemeta
Usage
eden('string')->quotemeta();
Example
eden('string')->set('Hello')->quotemeta();
====
repeat
Same as PHP: str_repeat
Usage
eden('string')->repeat();
Example
eden('string')->set('Hello')->repeat();
====
replace
Same as PHP: str_replace
Usage
eden('string')->replace();
Example
eden('string')->set('Hello')->replace();
====
rev
Same as PHP: strrev
Usage
eden('string')->rev();
Example
eden('string')->set('Hello')->rev();
====
rot13
Same as PHP: str_rot13
Usage
eden('string')->rot13();
Example
eden('string')->set('Hello')->rot13();
====
rtrim
Same as PHP: rtrim
Usage
eden('string')->rtrim();
Example
eden('string')->set('Hello')->rtrim();
====
sha1
Same as PHP: sha1
Usage
eden('string')->sha1();
Example
eden('string')->set('Hello')->sha1();
====
shuffle
Same as PHP: str_shuffle
Usage
eden('string')->shuffle();
Example
eden('string')->set('Hello')->shuffle();
====
sprintf
Same as PHP: sprintf
Usage
eden('string')->sprintf();
Example
eden('string')->set('Hello')->sprintf();
====
str
Same as PHP: strstr
Usage
eden('string')->str();
Example
eden('string')->set('Hello')->str();
====
substr
Same as PHP: substr
Usage
eden('string')->substr();
Example
eden('string')->set('Hello')->substr();
====
substrCompare
Same as PHP: substr_compare
Usage
eden('string')->substrCompare();
Example
eden('string')->set('Hello')->substrCompare();
====
substrCount
Same as PHP: substr_count
Usage
eden('string')->substrCount();
Example
eden('string')->set('Hello')->substrCount();
====
substrReplace
Same as PHP: substr_replace
Usage
eden('string')->substrReplace();
Example
eden('string')->set('Hello')->substrReplace();
====
tok
Same as PHP: strtok
Usage
eden('string')->tok();
Example
eden('string')->set('Hello')->tok();
====
tolower
Same as PHP: strtolower
Usage
eden('string')->tolower();
Example
eden('string')->set('Hello')->tolower();
====
toupper
Same as PHP: strtoupper
Usage
eden('string')->toupper();
Example
eden('string')->set('Hello')->toupper();
====
tr
Same as PHP: strtr
Usage
eden('string')->tr();
Example
eden('string')->set('Hello')->tr();
====
trim
Same as PHP: trim
Usage
eden('string')->trim();
Example
eden('string')->set('Hello')->trim();
====
ucfirst
Same as PHP: ucfirst
Usage
eden('string')->ucfirst();
Example
eden('string')->set('Hello')->ucfirst();
====
ucwords
Same as PHP: ucwords
Usage
eden('string')->ucwords();
Example
eden('string')->set('Hello')->ucwords();
====
vsprintf
Same as PHP: vsprintf
Usage
eden('string')->vsprintf();
Example
eden('string')->set('Hello')->vsprintf();
====
wordwrap
Same as PHP: wordwrap
Usage
eden('string')->wordwrap();
Example
eden('string')->set('Hello')->wordwrap();
====
Contributions to Eden are following the Github work flow. Please read up before contributing.
##Setting up your machine with the Eden repository and your fork
- Fork the repository
- Fire up your local terminal create a new branch from the
v4
branch of your fork with a branch name describing what your changes are. Possible branch name types:- bugfix
- feature
- improvement
- Make your changes. Always make sure to sign-off (-s) on all commits made (git commit -s -m "Commit message")
##Making pull requests
- Please ensure to run
phpunit
before making a pull request. - Push your code to your remote forked version.
- Go back to your forked version on GitHub and submit a pull request.
- An Eden developer will review your code and merge it in when it has been classified as suitable.