Map

An iterable container implementation


Package: dhii/map
Standards: PSR-11, Dhii Collection, Dhii Iterator

Details

The primary purpose of this package is to provide a concrete implementation of an iterable container. Because maps implement ContainerInterface, they can be used to retrieve values in an interoperable way. At the same time, because all Dhii Iterator implementations are Traversable, it is possible to retrieve all values of a map, which is useful for serialization, making it possible to cache an entire map. By extending a map, it could even be possible to generate the values in a map, such as from definitions, or from another data source, like a database or a REST API.

Using a factory, it is possible to produce a hierarchy of maps, thus forming a tree. Because in this tree maps contain other maps, the whole tree can also be processed in a generic, standard way - such as for serialization. For example CountableMapFactory, given an arbitrary tree of iterables, can produce a hierarchy of maps. This is the approach that is used by [Dhii Config][].