1001pharmacies/dictionary

A PHP library to manipulate Dictionary datastructure

Installs: 52

Dependents: 0

Stars: 13

Watchers: 12

Forks: 2

Language: PHP

v0.3.1 2014-12-10 11:33 UTC

README

Build Status Total Downloads Latest Stable Version

A simple class to manipulate Dictionary datastructures within PHP.

You probably dreamed one day to use objects as array indexes. So, that's what this library does.

$dictionary[new YourClass()] = '';

Installation

First, you need composer. Download it :

curl -sS https://getcomposer.org/installer | php

Look if he's installed :

php composer.phar

And then install the project :

php composer.phar install

In the composer.json of your project, add :

"require": {
    "1001pharmacies/dictionary": "0.*"
}

Usage example

<?php 
// example.php

require __DIR__.'/vendor/autoload.php';

use Meup\DataStructure\Dictionary;

$term              = new stdClass();
$term->label       = 'Lorem ipsum dolor sit amet';

$definition        = new stdClass();
$definition->label = 'Some sample text in latin';

$dictionary        = new Dictionary();
$dictionary[$term] = $definition;

You could use a dictionary with type restriction.

Running Tests

To run tests, execute the command :

vendor/bin/phing test

Compatibility

You need to use PHP 5.5 (or greater version) to enjoy this library. The Iterator::key() method could not return anything else than a scalar value (read more about this).