2017 © Pedro Peláez
 

library collection

Library to provide collection structures, to use instead of arrays

image

aircury/collection

Library to provide collection structures, to use instead of arrays

  • Saturday, February 3, 2018
  • by aircury
  • Repository
  • 1 Watchers
  • 0 Stars
  • 358 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 19 % Grown

The README.md

Collection

PHP Arrays with additional functionality. Arrays on steroids., (*1)

Usage

There are two ways of using this library. To create Collections of objects or Collections of PHP scalar types., (*2)

Object Collections

To create you own Collection, the easiest way is to copy and adjust the sample CarCollection, replacing Car with the class that you need., (*3)

More generically, these are the steps to create your own Collection: - Extend the AbstractCollection class - Implement on the child these methods, - getClass() to provide information about the expected class or interface that all the objects on the collection should be. - offsetGet($offset) to specify the return class. - toArray() to provide PHPDoc information about the elements of the array. - first() to specify the return class., (*4)

Scalar type Collections

This library comes out of the box with the following Collections, ready to use: - StringCollection - StringOrNullCollection - IntegerCollection - IntegerOrNullCollection, (*5)

These classes include additional expected functionality that you would expect from the data type, e.g. implode(), sum(), ..., (*6)

If they do not suit your needs, you can extend any of them or the AbstractScalarTypeCollection to implement your own., (*7)

The Versions

03/02 2018

dev-master

9999999-dev

Library to provide collection structures, to use instead of arrays

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires