2017 © Pedro Peláez
 

library heap

Easier handling for arrays in PHP. Collections 'lite'.

image

sven/heap

Easier handling for arrays in PHP. Collections 'lite'.

  • Thursday, January 12, 2017
  • by svenluijten
  • Repository
  • 1 Watchers
  • 3 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

heap, (*1)

Heap

Latest Version on Packagist ![Software License][ico-license] Build Status ![Total Downloads][ico-downloads], (*2)

Heap is a handy way of interacting with arrays in PHP. This package provides you with an easy to understand API and a much needed break from the mess that is PHP's built-in array functions., (*3)

Installation

Install this package via composer:, (*4)

``` bash $ composer require sven/heap, (*5)


Alternatively, add the package to your dependencies in your `composer.json` file and run `composer update`: ```json { "require": { "sven/heap": "0.0.2" } }

Usage

``` php, (*6)

New up an instance of the class.

$heap = new Sven\Heap\Heap;, (*7)

You can also pass in an array to push to the heap.

$heap = new Sven\Heap\Heap(['foo', 'bar', 'baz']);, (*8)


```php # Push an item into the heap. $heap->push('foo'); $heap->all(); // ['foo']
# Merge an existing array into the heap.
$heap->merge(['fizz', 'baz']);
$heap->all(); // ['foo', 'fizz', 'baz']
# Get the first or last item from the heap.
$heap->first(); // 'foo'
$heap->last(); // 'baz'

# Get the first or last `n` items from the heap.
$heap->first(2); // ['foo', 'fizz']
$heap->last(2); // ['fizz', 'baz']
# Pre- or append an item to the heap.
$heap->prepend('bar');
$heap->all(); // ['bar', 'foo', 'fizz', 'baz']

$heap->append('buzz');
$heap->all(); // ['bar', 'foo', 'fizz', 'baz', 'buzz']
$heap->random(); // 'baz' (retrieved randomly)
# Empty the entire array.
$heap->nuke();
$heap->all(); // []

Testing

bash $ composer test, (*9)

Security

If you discover any security related issues, please email svenluijten@outlook.com instead of using the issue tracker., (*10)

Credits

License

The MIT License (MIT). Please see License File for more information., (*11)

The Versions

12/01 2017

dev-master

9999999-dev

Easier handling for arrays in PHP. Collections 'lite'.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

collection array heap

12/04 2016

dev-develop

dev-develop

Easier handling for arrays in PHP. Collections 'lite'.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

collection array heap

10/03 2016

0.0.2

0.0.2.0

Easier handling for arrays in PHP. Collections 'lite'.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

collection array heap

10/03 2016

0.0.1

0.0.1.0

Easier handling for arrays in PHP. Collections 'lite'.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

collection array heap