src/ADT/List/Dictionary.php
public function cast( $value, $key )
	{
		if( strtolower( gettype( $value ) ) === "resource" )
			throw new InvalidArgumentException( 'Cannot cast resource' );
		if( !$this->has( $key ) )
			throw new OutOfRangeException( 'Invalid key "'.$key.'"' );

		$key		= !$this->caseSensitive ? strtolower( $key ) : $key;								//  lowercase key if dictionary is not case sensitive
		$valueType	= strtolower( gettype( $value ) );
		$pairType	= strtolower( gettype( $this->get( $key ) ) );

		$abstracts	= array( 'array', 'object' );
		if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) )
			throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType );
		settype( $value, $pairType );
		return $value;
	}
public function cast( $value, $key )
	{
		if( strtolower( gettype( $value ) ) === "resource" )
			throw new InvalidArgumentException( 'Cannot cast resource' );
		if( !$this->has( $key ) )
			throw new OutOfRangeException( 'Invalid key "'.$key.'"' );

		$key		= !$this->caseSensitive ? strtolower( $key ) : $key;								//  lowercase key if dictionary is not case sensitive
		$valueType	= strtolower( gettype( $value ) );
		$pairType	= strtolower( gettype( $this->get( $key ) ) );

		$abstracts	= array( 'array', 'object' );
		if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) )
			throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType );
		settype( $value, $pairType );
		return $value;
	}
public function cast ( $ value , $ key ) { if ( strtolower ( gettype ( $ value ) ) === "resource" ) throw new InvalidArgumentException ( 'Cannot cast resource' ) ; if ( ! $ this -> has ( $ key ) ) throw new OutOfRangeException ( 'Invalid key "' . $ key . '"' ) ; $ key = ! $ this -> caseSensitive ? strtolower ( $ key ) : $ key ; //  lowercase key if dictionary is not case sensitive
 $ valueType = strtolower ( gettype ( $ value ) ) ; $ pairType = strtolower ( gettype ( $ this -> get ( $ key ) ) ) ; $ abstracts = array ( 'array' , 'object' ) ; if ( in_array ( $ valueType , $ abstracts ) !== in_array ( $ pairType , $ abstracts ) ) throw new UnexpectedValueException ( 'Cannot cast ' . $ valueType . ' to ' . $ pairType ) ; settype ( $ value , $ pairType ) ; return $ value ; }
Casts a Value by the Type of the current Value by its Key.
@access		public
@param		string		$value		Value to cast
@param		string		$key		Key in Dictionary
@return		mixed
@throws		InvalidArgumentException	if value is a resource
@throws		OutOfRangeException			if key is not existing
@throws		UnexpectedValueException	if cast is not possible (like between string and array and vise versa)
Casts a Value by the Type of the current Value by its Key .