Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cloudcreativity/utils-collection
Our standard class for handling lists in PHP.
https://github.com/cloudcreativity/utils-collection
Last synced: 18 days ago
JSON representation
Our standard class for handling lists in PHP.
- Host: GitHub
- URL: https://github.com/cloudcreativity/utils-collection
- Owner: cloudcreativity
- License: apache-2.0
- Created: 2016-04-20T21:47:52.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2019-02-16T13:48:49.000Z (almost 6 years ago)
- Last Synced: 2024-11-30T13:41:50.267Z (24 days ago)
- Language: PHP
- Size: 64.5 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/cloudcreativity/utils-collection.svg?branch=master)](https://travis-ci.org/cloudcreativity/utils-collection)
# cloudcreativity/utils-collection
Our standard collection class for handling lists in PHP. By lists, we mean
numerically indexed arrays.This package also contains our `StandardIteratorInterface`. We use this if we
are writing specific collection classes that hold only particular types of
objects.## License
Apache License (Version 2.0). Please see [License File](LICENSE) for more information.
## Contributing
File an issue, or ideally submit a pull request. Bug fixes should be submitted against the `master` branch,
new features/changes should be submitted against the `develop` branch. Pull requests should have updated or new
unit tests in them.Make sure your IDE has an [EditorConfig](http://editorconfig.org) plugin installed.
## Testing
Clone the repository, then:
``` bash
composer up
vendor/bin/phpunit
```## Collection
The `CloudCreativity\Utils\Collection\Collection` is a standard class for
handling numerically indexed lists. It comes with the following methods.### Modifiers
The following methods modify the list contained within the collection:
* `add`
* `addStrict`
* `addObjects`
* `clear`
* `fill`
* `fillObject`
* `insertAt`
* `pop`
* `push`
* `pushObjects`
* `remove`
* `removeAt`
* `removeStrict`
* `replace`
* `shift`
* `unshift`
* `unshiftObjects`### Accessors
The following methods give access to items within the collection:
* `first`
* `itemAt`
* `last`### Querying
The following methods can be used to assess or query the contents of the
collection;* `any`
* `contains`
* `containsStrict`
* `equals`
* `equalsStrict`
* `every`
* `indexOf`
* `indexOfStrict`
* `isEmpty`
* `isNotEmpty`
* `search`
* `searchStrict`### Helpers
The following methods assist with handling the list, and return new instances
of the collection. (I.e. the original collection is not modified.)* `all`
* `cast` (static)
* `chunk`
* `compact`
* `copy`
* `count`
* `create` (static)
* `diff`
* `each`
* `filter`
* `implode`
* `intersect`
* `invoke`
* `itemsAt`
* `map`
* `pad`
* `reduce`
* `reject`
* `replicate`
* `reverse`
* `slice`
* `sort`
* `sync`
* `take`
* `tap`
* `unique`
* `uniqueStrict`
* `without`
* `withoutStrict`