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;
	}
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;
	}
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 ; }
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
Casts to string when necessary and checks if within max length