public function setItem($key, $item) {
		if (is_array($key)) {
			$key = $this->arrayHashFunction($key);
		}
		
		if (! isset($this->_data[$key])) {
			$this->_map[] = $key;
		}
		
		if (is_object($item)) {
			$modelClass = $this->getModel();
			if (! $item instanceof $modelClass) {
				throw new Exception('Model must be an instance of "' . $modelClass . '"');
			}
			
			$item->setCollection($this);
			
			$this->_data[$key]   = &$item->getDataLinked();
			$this->_models[$key] = $item;
		}
		elseif (is_array($item)) {
			$this->_data[$key] = $item;
		}
		else {
			throw new Exception('Unknown type of item: "' . gettype($item) . '"');
		}
		
		return $this;
	}
public function setItem($key, $item) {
		if (is_array($key)) {
			$key = $this->arrayHashFunction($key);
		}
		
		if (! isset($this->_data[$key])) {
			$this->_map[] = $key;
		}
		
		if (is_object($item)) {
			$modelClass = $this->getModel();
			if (! $item instanceof $modelClass) {
				throw new Exception('Model must be an instance of "' . $modelClass . '"');
			}
			
			$item->setCollection($this);
			
			$this->_data[$key]   = &$item->getDataLinked();
			$this->_models[$key] = $item;
		}
		elseif (is_array($item)) {
			$this->_data[$key] = $item;
		}
		else {
			throw new Exception('Unknown type of item: "' . gettype($item) . '"');
		}
		
		return $this;
	}
public function setItem ( $ key , $ item ) { if ( is_array ( $ key ) ) { $ key = $ this -> arrayHashFunction ( $ key ) ; } if ( ! isset ( $ this -> _data [ $ key ] ) ) { $ this -> _map [ ] = $ key ; } if ( is_object ( $ item ) ) { $ modelClass = $ this -> getModel ( ) ; if ( ! $ item instanceof $ modelClass ) { throw new Exception ( 'Model must be an instance of "' . $ modelClass . '"' ) ; } $ item -> setCollection ( $ this ) ; $ this -> _data [ $ key ] = & $ item -> getDataLinked ( ) ; $ this -> _models [ $ key ] = $ item ; } elseif ( is_array ( $ item ) ) { $ this -> _data [ $ key ] = $ item ; } else { throw new Exception ( 'Unknown type of item: "' . gettype ( $ item ) . '"' ) ; } return $ this ; }
Set an item

@param  string | int    $key
@param  array  | object $item
@throws Exception
@return Collection
Set an item