<commit_before><?php

/**
 * StringHelper class file
 *
 * @author tonylevid <<EMAIL>>
 * @link http://www.tframework.com/
 * @copyright http://tonylevid.com/
 * @license http://www.tframework.com/license/
 * @package helper
 */
class StringHelper {

    /**
     * Convert camel style string to underscore style string.
     * @param string $str String to be converted.
     * @return string
     */
    public static function camelToUnderscore($str) {
        return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str));
    }

    /**
     * Convert underscore style string to camel style string.
     * @param string $str String to be converted.
     * @return string
     */
    public static function underscoreToCamel($str) {
        return lcfirst(implode('', array_map('ucfirst', explode('_', $str))));
    }
    
    /**
     * Convert tag string like 'foo, bar,   barz，boom,，,' to 'foo,bar,barz,boom'.
     * @param string $str Input string.
     * @param mixed $search String or array indicates separator(s).
     * @param string $glue Imploded glue.
     * @return string
     */
    public static function trimTags($str, $search = array('，', ','), $glue = ',') {
        $replacedStr = str_replace($search, $glue, $str);
        $strParts = array_filter(array_map('trim', explode($glue, $replacedStr)));
        return implode($glue, $strParts);
    }

}<commit_msg>增加xmlToArray方法<commit_after><?php

/**
 * StringHelper class file
 *
 * @author tonylevid <<EMAIL>>
 * @link http://www.tframework.com/
 * @copyright http://tonylevid.com/
 * @license http://www.tframework.com/license/
 * @package helper
 */
class StringHelper {

    /**
     * Convert camel style string to underscore style string.
     * @param string $str String to be converted.
     * @return string
     */
    public static function camelToUnderscore($str) {
        return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str));
    }

    /**
     * Convert underscore style string to camel style string.
     * @param string $str String to be converted.
     * @return string
     */
    public static function underscoreToCamel($str) {
        return lcfirst(implode('', array_map('ucfirst', explode('_', $str))));
    }
    
    /**
     * Convert tag string like 'foo, bar,   barz，boom,，,' to 'foo,bar,barz,boom'.
     * @param string $str Input string.
     * @param mixed $search String or array indicates separator(s), defaults to array('，', ',').
     * @param string $glue Imploded glue.
     * @return string
     */
    public static function trimTags($str, $search = array('，', ','), $glue = ',') {
        $replacedStr = str_replace($search, $glue, $str);
        $strParts = array_filter(array_map('trim', explode($glue, $replacedStr)));
        return implode($glue, $strParts);
    }
    
    /**
     * Xml转换成数组
     * @param string $xmlStr xml字符串
     * @return array
     */
    public static function xmlToArray($xmlStr) {
        $xml = simplexml_load_string($xmlStr);
        return json_decode(json_encode($xml), true);
    }

}
{'fraction_non_alphanumeric': 0.15492957746478872, 'fraction_numerical': 0.0013101867016049786, 'mean_word_length': 2.856060606060606, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 9}, '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': '7362687', 'n_tokens_mistral': 981, 'n_tokens_neox': 968, 'n_words': 249}