2017 © Pedro Peláez
 

library collection

Powerful but easy to use collections with support for lazy loading

image

bapcat/collection

Powerful but easy to use collections with support for lazy loading

  • Wednesday, December 20, 2017
  • by LordMonoxide
  • Repository
  • 4 Watchers
  • 0 Stars
  • 301 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Build Status Coverage Status License, (*1)

Collection

A modular, trait-based collection library that puts control of your data back in your hands., (*2)

Installation

Composer

Composer is the recommended method of installation for Collection., (*3)

$ composer require bapcat/collection

GitHub

This package may also be downloaded from GitHub., (*4)

Features

Basic Collection Use

Collections make it easy to control access to your data in an object-oriented way. The standard implementation supports reading and writing, as well as standard foreach iteration., (*5)

$collection = new Collection(['k1' => 'v1']);

var_dump($collection->get('k1')); // 'v1'
var_dump($collection->size()); // 1

$collection->set('k2', 'v2');

$collection->add('v3');

// $collection == ['k1' => 'v1', 'k2' => 'v2', 'v3']

$collection->remove('k2');

// $collection == ['k1' => 'v1', 'v3']

foreach($collection as $k => $v) {
    //
}

Custom Collections

Collections are built with traits, so it's easy to pick-and-choose the features you want. For example, you may want a collection that can't be modified from the outside:, (*6)

class MyCollection implements ReadableCollectionInterface {
    use ReadableCollectionTrait;

    protected $collection = [];
}

If you would like to implement a full read/write collection, you may extend the basic Collection class:, (*7)

class MyCollection extends Collection {
    //
}

Or, you may implement the interfaces and trait:, (*8)

class MyCollection implements ReadableCollectionInterface, WritableCollectionInterface {
    use ReadableCollectionTrait, WritableCollectionTrait;
}

Array Access

If you would like to use array access with your collection, use the ArrayAccessCollection class or the ArrayAccessCollectionTrait trait., (*9)

Lazy Loading

Writable collections have support for lazy-loading built in. Lazy loading can be very useful, for example, in database interactions., (*10)

$collection->lazy(1, function($key) {
    return User::find($key);
});

The Versions

20/12 2017

dev-java-collections

dev-java-collections http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php ^7.1

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

09/03 2017

dev-master

9999999-dev http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

09/03 2017

0.3.0

0.3.0.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

27/04 2016

0.2.x-dev

0.2.9999999.9999999-dev http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

27/02 2016

0.2.1

0.2.1.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

27/02 2016

dev-master.CF.#13.define-lazy

dev-master.CF.#13.define-lazy http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

24/02 2016

dev-master.CF.#6.docs

dev-master.CF.#6.docs http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

24/02 2016

0.1.2

0.1.2.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

24/02 2016

0.2.0

0.2.0.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

19/02 2016

0.1.1

0.1.1.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only

22/11 2015

0.1

0.1.0.0 http://github.com/BapCat/Collection

Powerful but easy to use collections with support for lazy loading

  Sources   Download

GPLv3

The Requires

  • php >=5.6.0

 

The Development Requires

by Corey Frenette

collection array storage lazy read only