2017 © Pedro Peláez
 

library map

Implementation of map in PHP

image

wookieb/map

Implementation of map in PHP

  • Saturday, September 14, 2013
  • by wookieb
  • Repository
  • 1 Watchers
  • 1 Stars
  • 32 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Map

Build Status Implementation of map data type for PHP. Allows to use non-scalar keys like objects, arrays., (*1)

Install

Via composer, (*2)

    "require": {
        "wookieb/map": "0.1"
    }

Example

use Wookieb\Map\Map;

$map = new Map();

$object = new stdClass();

$map->add(true, 'that\'s true');
$map->add($object, 'some object');
$map->add('key', 'value');

$map->get(true); // that's true
$map->get($object); // some object
$map->get('key'); // value

Iteration

Since map may contains some non-scalar keys so iteration is different. For php < 5.5 you will receive a MapEntry object instead of value of current element in iteration. For php >= 5.5 iteration works normally., (*3)


use Wookieb\Map\Map; $map = new Map(); $map->add('yearly', 'ketchup'); // for php < 5.5 foreach ($map as $entry) { list($key, $value) = $entry->get(); $key; // yearly $value; // ketchup // or $entry->getKey(); // yearly $entry->getValue(); // ketchup } // for php >= 5.5 foreach ($map as $key => $value) { $key; // yearly $value; // ketchup } // forcing map to use MapEntry objects $map = new Map(true); $map->add('yearly', 'ketchup'); // for every php version foreach ($map as $entry) { list($key, $value) = $entry->get(); }

Changelog

0.1.2

  • added isUsingMapEntries method

0.1.1

  • added StrictMapTypeCheck

The Versions

14/09 2013

dev-master

9999999-dev

Implementation of map in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

map data structure

14/09 2013

0.1.2

0.1.2.0

Implementation of map in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

map data structure

14/09 2013

0.1.1

0.1.1.0

Implementation of map in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

map data structure

12/09 2013

0.1

0.1.0.0

Implementation of map in PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

map data structure