nia/collection-map-stringmap

nia component for string maps.

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.0.1 2016-02-21 17:27 UTC

This package is not auto-updated.

Last update: 2022-03-10 22:01:23 UTC


README

String maps encapsulate a native php string assoc array and provides common methods.

Installation

Require this package with Composer.

	composer require nia/collection-map-stringmap

Tests

To run the unit test use the following command:

$ cd /path/to/nia/component/
$ phpunit --bootstrap=vendor/autoload.php tests/

How to use

The following sample shows you how to use the string map component and to decorate the map to a read-only map.

	// create a read/write map.
	$map = new Map([
	    'foo' => '123',
	    'bar' => '456'
	]);

	// add 'baz' and remove 'bar'
	$map->set('baz', '789')->remove('bar');

	foreach ($map as $name => $value) {
	    var_dump($name, $value);
	}

	// make it read-only (ReadOnlyMap does not contain any methods to manipulate the map)
	$map = new ReadOnlyMap($map);

	foreach ($map as $name => $value) {
	    var_dump($name, $value);
	}