dev-master
9999999-devsortable collections of items
MIT
The Requires
- php ^7.0
The Development Requires
by Robert Asproniu
dev-develop
dev-developsortable collections of items
MIT
The Requires
- php ^7.0
The Development Requires
by Robert Asproniu
Wallogit.com
2017 © Pedro Peláez
sortable collections 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
});
sortable collections of items
MIT
sortable collections of items
MIT