/** * Adds an item into the map. * This method overrides the parent implementation by * checking the item to be inserted is of certain type. * @param integer $index the specified position. * @param mixed $item new item * @throws Kohana_Exception If the index specified exceeds the bound, * the map is read-only or the element is not of the expected type. */ public function add($index, $item) { if ($item instanceof $this->_type) { parent::add($index, $item); } else { throw new Kohana_Exception('Collection_Typed_Map<:type> can only hold objects of :type class.', array(':type' => $this->_type)); } }
/** * Determines whether a property can be read. * This method overrides parent implementation by returning TRUE * if the collection contains the named key. * @param string $name the property name * @return boolean whether the property can be read */ public function can_get_property($name) { return $this->contains($name) or parent::contains($name); }