2017 © Pedro Peláez
 

library phpcollections

A set of collections for PHP.

image

maxalmonte14/phpcollections

A set of collections for PHP.

  • Thursday, November 2, 2017
  • by maxalmonte14
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

StyleCI Scrutinizer Code Quality Build Status, (*1)

About PHPCollections

PHPCollections is a set of data structures that try to make your life easier when you're working with PHP and large sets of data. Inspired by languages like Java or C#, PHPCollections offers data structures like List, Map, Stack and more, check it out!, (*2)

Requirements

PHP >= 7.2

Installation

composer require "maxalmonte14/phpcollections"

Examples

Imagine you're storing Post objects for fetching like so., (*3)

$posts[] = new Post(1, 'PHP 7.2 release notes');
$posts[] = new Post(2, 'New Laravel 5.5 LTS make:factory command');

Everything is fine! But maybe you made a mistake for some mysterious reason and added a non-Post object., (*4)

$posts[] = 5 // This is not even an object!

When you'll try to fetch your posts array you'll be in troubles., (*5)

<?php foreach($posts as $post): ?>
    <tr>
        <!-- this gonna fail when $post == 5! -->
        <td><?= $post->id; ?></td>
        <td><?= $post->title; ?></td>
    </tr>
<?php endforeach ?>

Fortunately PHPCollections exists., (*6)

$posts = new GenericList(
    Post::class,
    new Post(1, 'PHP 7.2 release notes'),
    new Post(2, 'New Laravel 5.5 LTS make:factory command')
);
$posts->add(5); // An InvalidArgumentException is thrown!

Of course there exist more flexible data structures like ArrayList., (*7)

$posts = new ArrayList();
$posts->add(new Post(1, 'PHP 7.2 release notes'));
$posts->add(new Post(2, 'New Laravel 5.5 LTS make:factory command'));
$posts->add(5); // Everything is fine, I need this 5 anyway

Features

  • Different types of collections like Dictionary, Stack and GenericList.
  • Simple API.
  • Lightweight, no extra packages needed.

The Versions

02/11 2017

dev-master

9999999-dev

A set of collections for PHP.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Max Almonte

collection

02/11 2017

dev-develop

dev-develop

A set of collections for PHP.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Max Almonte

collection

02/11 2017

v0.5.0

0.5.0.0

A set of collections for PHP.

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Max Almonte

collection