Download the PHP package enzyme/collection without Composer

On this page you can find all versions of the php package enzyme/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

Collection

Build Status Coverage Status Scrutinizer Code Quality StyleCI

An all encompassing array manager.

Installation

Usage

You can create a collection from a standard PHP array. Once you have a collection, you can make use of all the methods it exposes.

The collection implements ArrayAccess, Iterator and Countable, so you can use it as a standard array.

In the example above, the equivalent and much more readable method would be $collection->first().

Available methods

Method signature Description
count() Return the number of elements in the collection.
each(Closure $fn) Execute the callback function provided on each item in the collection. The callback function is passed $value, $key as arguments. If the callback returns false, the function will return early and will not continue iterating over the remaining items left in the collection.
except(array $keys) Return a new collection containing all the keys in the current collection except those whose keys match the ones provided.
filter(Closure $fn) Return a new collection will all items that pass the given callback functions truth test.
first() Get the value of the first item in the collection. If the collection is empty, a CollectionException will be thrown.
firstOrDefault($default = null) Same as above, except instead of throwing an exception, return the provided default value.
get($key) Get the value associated with the specified key. If the key does not exist, a CollectionException will be thrown.
getOrDefault($key, $default = null) Same as above, except instead of throwing an exception, return the provided default value.
has($key, $value = null) Checks whether the collection has the specified key, and/or key/value pair.
hasCount($min, $max = null) Checks whether the collection has the minimum count specified, or a count that falls within the range specified.
isEmpty() Whether the collection is empty.
keys() Returns an array of all the keys used by the collection.
last() Get the value of the last item in the collection. If the collection is empty, a CollectionException will be thrown.
lastOrDefault($default = null) Same as above, except instead of throwing an exception, return the provided default value.
make(array $initial) static Static helper method to instantiate a new collection. Useful for when you want to immediately chain a method. Eg: Collection::make([1, 2, 3])->map(...)
map(Closure $fn) Execute the callback function provided on each item in the collection. The callback function is passed $value, $key as arguments. The return value of the callback function will be saved into a new collection and that collection will be returned as a result
mapWithKey(Closure $fn) Execute the given callback function for each element in this collection and save the results to a new collection with the specified key. The callback function should return a 1 element associative array, eg: ['key' => 'value'] to be mapped.
only(array $keys) Return a new collection containing only the items in the current collection whose keys match the ones provided.
pluck($pluck_key, $deep = true) Grab and return a new collection will all values that have the specified key. By default, this will traverse multidimensional arrays.
push($value) Return a new collection with the given value pushed onto a copy of the current collection's items.
pushArray(array $data) Return a new collection with the given array pushed onto a copy of the current collection's items.
pushWithKey($key, $value) Return a new collection with the given key/value pair pushed onto a copy of the current collection's items.
sort(Closure $fn) Return a new collection after the user defined sort function has been executed on the items. Same callback function parameters as the PHP usort function.
toArray() Returns the current collection as a standard PHP array.

Contributing

Please see CONTRIBUTING.md

License

MIT - Copyright (c) 2016 Tristan Strathearn, see LICENSE


All versions of collection with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
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 enzyme/collection contains the following files

Loading the files please wait ....