2017 © Pedro Peláez
 

library collection

A set of interfaces and traits to speed up the creation of collections

image

ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  • Friday, April 25, 2014
  • by ebidtech
  • Repository
  • 14 Watchers
  • 13 Stars
  • 42,318 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 7 % Grown

The README.md

Collection

A set of interfaces and traits to speed up the creation of collections., (*1)

Latest Stable Version Build Status Coverage Status Scrutinizer Quality Score Dependency Status, (*2)

Requirements

  • PHP >= 5.4

Installation

The recommended way to install is through composer., (*3)

Just create a composer.json file for your project:, (*4)

``` json { "require": { "ebidtech/collection": "@stable" } }, (*5)


**Tip:** browse [`ebidtech/collection`](https://packagist.org/packages/ebidtech/collection) page to choose a stable version to use, avoid the `@stable` meta constraint. And run these two commands to install it: ```bash $ curl -sS https://getcomposer.org/installer | php $ composer install

Now you can add the autoloader, and you will have access to the library:, (*6)

<?php

require 'vendor/autoload.php';

Usage

Collection class example:, (*7)

use EBT\Collection\CollectionDirectAccessInterface;
use EBT\Collection\CountableTrait;
use EBT\Collection\DirectAccessTrait;
use EBT\Collection\EmptyTrait;
use EBT\Collection\GetItemsTrait;
use EBT\Collection\IterableTrait;

/**
 * TestCollection
 */
class TestCollection implements CollectionDirectAccessInterface
{
    use CountableTrait;
    use DirectAccessTrait;
    use EmptyTrait;
    use GetItemsTrait;
    use IterableTrait;

    /**
     * @var array
     */
    protected $items = array(
        'test1' => 'val1',
        'test2' => 'val2',
        'test3' => 'val3'
    );
}

From outside you can: * iterate (due to IterableTrait) * direct access using get() (due to DirectAccessTrait) * use count() (due to CountableTrait), (*8)

Outside access example:, (*9)

$collection = new TestCollection();
echo count($collection); // will print 3
echo $collection->get('test1');  // will print val1
foreach ($collection as $key => $val) {
    // will result in:
    // test1 val1
    // test2 val2
    // test3 val3
    echo sprintf("%s %s", $key, $val);
}

Notes: * Traits use have an abstract getCollection() method that needs to be implemented on collection class, the GetCollectionTrait makes a simple implementation, you can override it if the property that holds the internal array is not named collection, (*10)

Upgrading

Upgrade, (*11)

Contributing

See CONTRIBUTING file., (*12)

Credits

License

Collection library is released under the MIT License. See the bundled LICENSE file for details., (*13)

The Versions

25/04 2014

dev-master

9999999-dev http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

01/02 2014

v2.0.1

2.0.1.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

01/02 2014

v2.0

2.0.0.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

04/12 2013

v1.1.1

1.1.1.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

03/12 2013

v1.1

1.1.0.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

28/11 2013

v1.0.1

1.0.1.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

28/11 2013

v1.0

1.0.0.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction

28/11 2013

v0.1

0.1.0.0 http://github.com/ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar ebidtech

php library collection trait abstraction