https://github.com/jjgrainger/collection
A PHP Collection class for working with arrays
https://github.com/jjgrainger/collection
collection php
Last synced: 12 months ago
JSON representation
A PHP Collection class for working with arrays
- Host: GitHub
- URL: https://github.com/jjgrainger/collection
- Owner: jjgrainger
- License: mit
- Created: 2017-01-02T17:39:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-04-07T15:51:33.000Z (about 6 years ago)
- Last Synced: 2025-05-16T17:45:04.297Z (about 1 year ago)
- Topics: collection, php
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Collection v1.1
> A collection class for working with arrays
[](https://travis-ci.org/jjgrainger/Collection) [](https://packagist.org/packages/jjgrainger/collection) [](https://packagist.org/packages/jjgrainger/collection) [](https://packagist.org/packages/jjgrainger/collection)
## Principles
* Immutable - Most methods return a new collection, leaving the previous untouched
* Chainable - Methods can be chained to create fluent mapping and reduce original collection
## Requirements
* PHP >=7.2
* [Composer](https://getcomposer.org/)
## Installation
```
$ composer require jjgrainger/collection
```
## Usage
```php
$collection = new Collection([1, 2, 3]);
$total = $collection->sum(); // 6
```
## Notes
* This project was created to learn unit testing, not intended for production use.
* Inspired by [Laravel Collections](https://laravel.com/docs/5.8/collections)
* Licensed under the [MIT License](https://github.com/jjgrainger/wp-posttypes/blob/master/LICENSE)
* Maintained under the [Semantic Versioning Guide](https://semver.org)
## Author
**Joe Grainger**
* [https://jjgrainger.co.uk](https://jjgrainger.co.uk)
* [https://twitter.com/jjgrainger](https://twitter.com/jjgrainger)