original_string: public static function type_string($var, array $settings)
  	{
  		if (is_array($var) or (is_object($var) and ! method_exists($var, '__toString')))
  		{
  			throw new InvalidContentType('Array or object could not be converted to varchar.');
  		}
  
  		$var = strval($var);
  
  		if (array_key_exists('character_maximum_length', $settings))
  		{
  			$length  = intval($settings['character_maximum_length']);
  			if ($length > 0 and strlen($var) > $length)
  			{
  				$var = substr($var, 0, $length);
  			}
  		}
  
  		return $var;
  	}
code: public static function type_string($var, array $settings)
  	{
  		if (is_array($var) or (is_object($var) and ! method_exists($var, '__toString')))
  		{
  			throw new InvalidContentType('Array or object could not be converted to varchar.');
  		}
  
  		$var = strval($var);
  
  		if (array_key_exists('character_maximum_length', $settings))
  		{
  			$length  = intval($settings['character_maximum_length']);
  			if ($length > 0 and strlen($var) > $length)
  			{
  				$var = substr($var, 0, $length);
  			}
  		}
  
  		return $var;
  	}
code_tokens: public static function type_string ( $ var , array $ settings ) { if ( is_array ( $ var ) or ( is_object ( $ var ) and ! method_exists ( $ var , '__toString' ) ) ) { throw new InvalidContentType ( 'Array or object could not be converted to varchar.' ) ; } $ var = strval ( $ var ) ; if ( array_key_exists ( 'character_maximum_length' , $ settings ) ) { $ length = intval ( $ settings [ 'character_maximum_length' ] ) ; if ( $ length > 0 and strlen ( $ var ) > $ length ) { $ var = substr ( $ var , 0 , $ length ) ; } } return $ var ; }
docstring: Casts to string when necessary and checks if within max length
  
  @param   mixed  value to typecast
  @param   array  any options to be passed
  
  @throws  InvalidContentType
  
  @return  string
docstring_tokens: Casts to string when necessary and checks if within max length