/** * 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)); } }
/** * Adds an item into the map. * This overrides the parent implementation by converting the key to lower case first if {@link case_sensitive} is FALSE. * @param mixed $key key * @param mixed $value value */ public function add($key, $value) { if ($this->case_sensitive) { parent::add($key, $value); } else { parent::add(strtolower($key), $value); } }