Download the PHP package transprime-research/arrayed without Composer
On this page you can find all versions of the php package transprime-research/arrayed. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download transprime-research/arrayed
More information about transprime-research/arrayed
Files in transprime-research/arrayed
Package arrayed
Short Description PHP Array(ed) in object oriented way wrapping PHP arrays in a consistent manner.
License MIT
Homepage https://transprime-research.github.io/arrayed/
Informations about the package arrayed
About Arrayed
Simple PHP Array(ed) in object oriented way wrapping PHP Arrays in a consistent manner.
No advanced stuff, just wrap PHP array_* functions and a little more. Do it Like a PRO :ok:
Looking for PHP Array on Steroid? See: https://laravel.com/docs/collections
Quick Usage
Instead of:
PS: You can still use the old
function() { return v; },fn()is the new short arrow function in PHP 7.4+ See: https://www.php.net/manual/en/functions.arrow.php
Installation
Requirement
Minimum Requirement
- PHP 7.2 +
-
Composer
- For using
collect()method, requiresilluminate\support>= 5.5Additionally on Laravel App, if
arrayed.php's config file doesn't get added automatically then runphp artisan vendor:publish --tag=arrayedafter installation.
Other Usages
Arrayed can be instantiated in 3 ways:
Initial values can be passed in two ways:
With Laravel & Laravel Collection
Laravel Collections
New: collect() method :tada:
In the future, changing the default Collection class will possible by editing
config/arrayed.php's collection_class value
Others:
Laravel Response accepts Arrayed:
Special methods
New :tada: tap() method allows other actions on the last resulting Arrayed instance without mutating the last Arrayed result:
Others
If any operation normally returns an array, the return value will give Arrayed instance so that other methods can be chained on them otherwise a non-array value is returned as can be seen that sum() returns an integer in the example below:
Example:
You can work on a result (if its an array'ed value) by passing a closure/callable function to result() method:
Get the original array data with raw() method
Piped calls
As at now not all array_* functions have been implemented.
pipe() method helps to call custom function on the array result.
Such as array_unique used in this way:
The pipe method makes use of Piper - A PHP functional pipe'ing See
\Transprime\Arrayed\Tests\ArrayedTest
Proxied calls
array_* methods that are not yet implemented are automatically proxied to call an array method with the assumption that they accept initial array first. Example is this:
Coming Soon
-
Implement other
array_*methods - pipe into Collection with
collectPipe
Api implementation to be decided
APIs
These are the API's available:
Additional Information
This package is part of a series of "Code Dare"
See other packages in this series here:
- https://github.com/transprime-research/piper [A functional PHP pipe in object-oriented way]
- https://github.com/omitobi/conditional [A smart PHP if...elseif...else statement]
- https://github.com/transprime-research/attempt [A smart PHP try...catch statement]
- https://github.com/omitobi/corbonate [A smart Carbon + Collection package]
- https://github.com/omitobi/laravel-habitue [Jsonable Http Request(er) package with Collections response]
Similar packages
- https://github.com/cocur/chain - Very identical, but without Piper
- https://github.com/bocharsky-bw/Arrayzy - Identical but with more actions and features
- https://github.com/voku/Arrayy - Perform more than just an OOP style on Arrays
- https://github.com/dantodev/php-array-tools - array tools plus collections
- https://github.com/minwork/array - Pack of advanced PHP array functions
- https://github.com/mblarsen/arrgh - A Sane PHP Array library with advance functions
- More at: https://www.google.com/search?q=php+array+github
Licence
MIT (See LICENCE file)