<commit_before><?php

class EarthIT_CMIPREST_RequestParser_Util
{
	public static function m( $bif, $idx ) {
		return isset($bif[$idx]) && $bif[$idx] != '' ? $bif[$idx] : null;
	}
	
	public static function parseQueryString( $queryString ) {
		$params = array();
		if($queryString) parse_str($queryString, $params);
		return $params;
	}
	
	public static function buildQueryString( array $stuff ) {
		$p = array();
		foreach( $stuff as $k=>$v ) {
			$p[] = urlencode($k).'='.urlencode($v);
		}
		return implode('&',$p);
	}
	
	public static function parseJsonContent( Nife_Blob $content=null ) {
		if( $content === null ) return null;
		if( $content->getLength() == 0 ) return null;
		if( $content instanceof EarthIT_JSON_PrettyPrintedJSONBlob ) return $content->getValue();
		$c = (string)$content;
		if( $c == '' ) return null;<commit_msg>Some @api comments on query string parser/builder functions in RequestParser/Util.<commit_after><?php

class EarthIT_CMIPREST_RequestParser_Util
{
	public static function m( $bif, $idx ) {
		return isset($bif[$idx]) && $bif[$idx] != '' ? $bif[$idx] : null;
	}
	
	/**
	 * @api
	 */
	public static function parseQueryString( $queryString ) {
		$params = array();
		if($queryString) parse_str($queryString, $params);
		return $params;
	}
	
	/**
	 * @api
	 * Here as a counterpart to parseQueryString, because sometimes you
	 * need to go that way.
	 */
	public static function buildQueryString( array $stuff ) {
		$p = array();
		foreach( $stuff as $k=>$v ) {
			$p[] = urlencode($k).'='.urlencode($v);
		}
		return implode('&',$p);
	}
	
	public static function parseJsonContent( Nife_Blob $content=null ) {
		if( $content === null ) return null;
		if( $content->getLength() == 0 ) return null;
		if( $content instanceof EarthIT_JSON_PrettyPrintedJSONBlob ) return $content->getValue();
		$c = (string)$content;
		if( $c == '' ) return null;
{'fraction_non_alphanumeric': 0.1664, 'fraction_numerical': 0.0010666666666666667, 'mean_word_length': 4.329545454545454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3302718', 'n_tokens_mistral': 681, 'n_tokens_neox': 624, 'n_words': 164}