2017 © Pedro Peláez
 

library collection

Lightweight collection library

image

phlak/collection

Lightweight collection library

  • Monday, September 25, 2017
  • by PHLAK
  • Repository
  • 2 Watchers
  • 2 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Collection

Latest Stable Version Total Downloads Author License Build Status StyleCI, (*1)

Lightweight collection library -- by, Chris Kankiewicz, (*2)

Requirements

Install with Composer

composer require phlak/collection

Initializing the Client

First, import Collection:, (*3)

use PHLAK\Collection;

Then pass an array of items to the Collection class or the static make method:, (*4)

$collection = new Collection\Collection(['foo', 'bar', 'baz']);

// or

$collection = Collection\Collection::make(['foo', 'bar', 'baz']);

Usage

Iterate over each item in a collection and perform an action via a Closure:, (*5)

$collection->each(Closure $function);

Map each item of the collection to a new value via a Closure:, (*6)

$collection->map(Closure $function);

Filter the items in a collection by returning only the items where the Closure returns true:, (*7)

$collection->filter(Closure $function);

Filter the items in a collection by returning only the items where the Closure returns false (opposite of the filter method):, (*8)

$collection->reject(Closure $function);

Reduce a collection down to a single item by iterating over the Closure until a single item remains:, (*9)

$collection->reduce(Closure $function, $initial);

Sum all the items in a collection and return the value:, (*10)

$collection->sum(Closure $function, $initial);

Changelog

A list of changes can be found on the GitHub Releases page., (*11)

Troubleshooting

Please report bugs to the GitHub Issue Tracker., (*12)

This project is liscensed under the MIT License., (*13)

The Versions

25/09 2017

dev-master

9999999-dev

Lightweight collection library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

04/09 2017

0.1.0

0.1.0.0

Lightweight collection library

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires