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
Since: 3.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends Prado\TComponent, implements IteratorAggregate, implements ArrayAccess, implements Countable
Example #1
0
 /**
  * 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);
 }
Example #2
0
 public function testToArray()
 {
     $map = new TMap(array('key' => 'value'));
     self::assertEquals(array('key' => 'value'), $map->toArray());
 }