2017 © Pedro Peláez
 

library php-sortable-collections

sortable collections of items

image

robertasproniu/php-sortable-collections

sortable collections of items

  • Wednesday, May 24, 2017
  • by robert.asproniu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Sortable Collection of Items

An example package that allows to create, merge and sort collections of items., (*1)

Collections are sorted using custom algorithm wich can be found in SortableArray.php file, (*2)

To install use:, (*3)

composer require robertasproniu/php-sortable-collections dev-master

To run the tests:, (*4)

./vendor/bin/phpunit

Creating a collection, (*5)

use SortableCollection\Collection\Collection;
$collection = new Collection($items); // where $items = []

or using a factory class, (*6)

use SortableCollection\CollectionFactory;
use SortableCollection\Collection\Collection;

class CustomCollectionFactory extends CollectionFactory
{
    public static function create($items) : CollectionInterface
    {
        // do whatever you need 

        return new Collection($items);
    }
}

$collection = CustomCollectionFactory::create($data); 

Get items from collection, (*7)

$collection->get(); // return array

Remove duplicate values from a collection, (*8)

$collection->unique();

Sort collection values, (*9)

$collection->sort(function($value1, $value2){
    //conditions
});

The Versions

24/05 2017

dev-master

9999999-dev

sortable collections of items

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Robert Asproniu

24/05 2017

dev-develop

dev-develop

sortable collections of items

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Robert Asproniu