Skip to content

Latest commit

 

History

History
66 lines (47 loc) · 1.92 KB

README.md

File metadata and controls

66 lines (47 loc) · 1.92 KB

Arrayze

Build Status Coverage Status Scrutinizer Code Quality

Give your values a lazy and functional array interface!

What is Arrayze?

Arrayze gives you an adapter for ArrayAccess and Traversable php interfaces. The adapter is built from a collection of callbacks, that maps the original value to runtime-computed values.

This means that you can easily give your objects or values an array-like interface, specifying how to compute offsets through callbacks.

Example

Let's suppose you have a Person class:

class Person
{
    private $firstName;
    private $lastName;
    private $birthYear;

    public function __construct($firstName, $surname, $birthYear) { ... }

    public function getFirstName() { return $this->firstName; }
    public function getLastName() { return $this->lastName; }
    public function getBirthYear() { return $this->birthYear; }
}

You specify then a collection of maps:

Install

The best way to install Arrayze is through composer.

Just create a composer.json file for your project:

{
    "require": {
        "nicmart/arrayze": "~0.1"
    }
}

Then you can run these two commands to install it:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

or simply run composer install if you have have already installed the composer globally.

Then you can include the autoloader, and you will have access to the library classes:

<?php
require 'vendor/autoload.php';