Download the PHP package colindecarlo/collection without Composer

On this page you can find all versions of the php package colindecarlo/collection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package collection

Build Status

Collection

Collection is a library geared towards delivering a fast and intuitive interface over a group of related elements.

Defining a Collection

Collections can be constructed in multiple ways by passing:

Defining an Empty Collection

Empty collections are created by passing an integer to the Collection constructor indicating its capacity. All indexes of the collection are initalized to null and the size of the collection is reported as 0.

Defining a Collection Derived From An array or SplFixedArray

Collections can be defined using a populated array (or SplFixedArray) simply by passing the array to Collection constructor. The size of the Collection is determined by finding the last non-null index of the array.

Using Collection

map($func)

Use map to create a new instance of Collection which contains a projection of each element of the mapped collection. The projection is created by applying the function contained in $func to each element of the original collection.

Parameters

`$func`
The function which is applied to each element of the collection. `$func` can be any [callable](callable) function.

Example

each($func)

Apply $func to each element of the collection. each returns the original collection so you can chain other methods off of it.

Parameters

`$func`
The function which is applied to each element of the collection. `$func` can be any [callable](callable) function.

Example

reduce($func, $intial)

Generate a single aggregate value derived from applying $func to each element of the collection.

Parameters

`$func`
The reducer function, this function accepts two parameters, `$carry` and `$elem` (in that order) where `$carry` is the current value of the reduction and `$elem` is the current element in the collection being reduced. `$func` can be any [callable](callable) function.
`$initial`
The initial value to be used in the reduction

Example

filter($func = null)

Return a new Collection containing the elements for which $func returns true. If $func is not passed to filter then only truthy values contained in the original collection will be present in the result.

Parameters

`$func`
The filter function for which each element of the collection is passed through. `$func` returns `true` if the element should be kept and `false` if not.

Example

slice($offset, $length = null)

flatten($flattenWith = null)

Transform a multi-dimensional collection into a one dimensional collection. The responsibilty of $flattenWith is to accept an element of the collection and return an arrray (or an object that implements both ArrayAccess) of the elements contained within that element. If a flattenWith function is not provided to flatten then the method will attempt to flatten the collection using a generic flattenWith function, this is useful for flattening a 2 dimensional collection.

Parameters

`$func`
This function is used to flatten individual elements into single dimensional array.

Example

contains($value)

first($matching = null)

last($matching = null)

reverse()

groupBy($getGroupKey)

prepend($elem)

append($elem)

push($elem)

pop()

toArray()

count()

Author

Colin DeCarlo, [email protected]

License

Collection is licensed under the MIT License - see the LICENSE file for details


All versions of collection with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package colindecarlo/collection contains the following files

Loading the files please wait ....