TMap implements a collection that takes key-value pairs.
You can access, add or remove an item with a key by using
{@link itemAt}, {@link add}, and {@link remove}.
To get the number of the items in the map, use {@link getCount}.
TMap can also be used like a regular array as follows,
$map[$key]=$value; // add a key-value pair
unset($map[$key]); // remove the value with the specified key
if(isset($map[$key])) // if the map contains the key
foreach($map as $key=>$value) // traverse the items in the map
$n=count($map); // returns the number of items in the map
/** * Determines whether a property can be read. * This method overrides parent implementation by returning true * if the collection contains the named key. * @param string the property name * @return boolean whether the property can be read */ public function canGetProperty($name) { return $this->contains($name) || parent::canGetProperty($name); }
public function testToArray() { $map = new TMap(array('key' => 'value')); self::assertEquals(array('key' => 'value'), $map->toArray()); }