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. Email us for help if needed.
Installs: 727
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nia/collection-map-stringmap
Requires
- php: >=7.0.0
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); }