/*
转成带无声调的汉语拼音
param $inputChar String  需要转换的汉字
param $delimiter  String   转换之后拼音之间分隔符
param $outsideIgnore  Boolean     是否忽略非汉字内容
977137
public function transformWithoutTone($inputChar, $delimiter=' ', $outsideIgnore=true)
    {
        $charWithTone = $this->transformWithTone($inputChar, $delimiter, $outsideIgnore);

        $charWithoutTone = str_replace(
            array('ā', 'á', 'ǎ', 'à', 'ō', 'ó', 'ǒ', 'ò', 'ē', 'é', 'ě', 'è', 'ī', 'í', 'ǐ', 'ì', 'ū', 'ú', 'ǔ', 'ù', 'ǖ', 'ǘ', 'ǚ', 'ǜ', 'ü'), 
            array('a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'v', 'v', 'v', 'v', 'v'),
            $charWithTone
        );

        return $charWithoutTone;

    }
1321596
public static function camelCaseToUnderline($camelCaseStr, $separator = '_')
    {
        $temp_array = array();
        for ($i = 0; $i < strlen($camelCaseStr); $i++) {
            $ascii_code = ord($camelCaseStr[$i]);
            if ($ascii_code >= 65 && $ascii_code <= 90) {
                $temp_array[] = $separator . chr($ascii_code + 32);
            } else {
                $temp_array[] = $camelCaseStr[$i];
            }
        }
        return implode('', $temp_array);
    }
535741
private static function isDelimiter($char, array $delimiters = null)
    {
        if (null === $delimiters) {
            return \ctype_space($char);
        }

        foreach ($delimiters as $delimiter) {
            if ($char === $delimiter) {
                return true;
            }
        }

        return false;
    }
646880
public function setInputArgsDelimiter($input_args_delimiter)
    {

        //parse arguments by removing path
        $args = preg_replace("~^.{" . strlen($this->path) . "}/?~", "", $this->request);

        //remove $_GET string
        $args = preg_replace("~\?.*?$~", "", $args);

        if ($args !== '') {

            $this->args = explode($input_args_delimiter, $args);

            //decodes url encoding
            foreach ($this->args as &$arg) {
                $arg = urldecode($arg);
            }

            if (method_exists('\App', 'filterAllInput')) {
                \App::filterAllInput($this->args);
            }
        }
    }
1321133
private static function _handleTypeOutput($data, $hasType = true, $mark = true, $outString = '')
    {
        # 常规打印，不含有类型
        if (!$hasType) {
            return self::_handleNormalOutput($data);
        }

        $jsClass = self::$controlClass;
        $html = 'htmlspecialchars';
        $ucfirst = 'ucfirst';
        static $i = 1;
        $usualString = "<dt><div class=\"array-value\">\n%s</div></dt>\n";
        $outString .= '<dl>' . PHP_EOL;
        $dataType = gettype($data);

        // if (is_object($data)) $data = (array)$data;
        # 含类型打印
        if (is_array($data)) {
            $count = 'count';
            $mark && $outString .= "<dt>\n<span class=\"print-icon icon-hide\"></span><div class=\"{$jsClass}\" style=\"width:98%\">" .
                "<strong class=\"general-print-color-dg\">{$ucfirst($dataType)}</strong>(size:<strong>{$count($data)}</strong>)<strong>(</strong></div>\n</dt>\n";
            $outString .= '<!-- .general-print-ar-content -->' . PHP_EOL . '<dd class="general-print-ar-content">';
            $tab = self::_getTab($i);

            foreach ($data as $k => $v) {
                $vType = gettype($v);
                $k = is_int($k) ? $k : "'{$html($k,ENT_QUOTES)}'";
                $outString .= "\n<dl>\n<dt><div class=\"array-key\">$tab$k</div>";

                if (is_array($v) || is_object($v) || is_resource($data)) {//
                    $outString .= "<div class=\"array-value {$jsClass}\"> &rArr; <strong class=\"general-print-color-dg\">{$ucfirst($vType)}</strong>(size:";

                    if (empty($v)) {
                        $outString .= '0)<strong>()</strong> </div><span class="print-icon icon-hide"></span></dt>';
                        continue;
                    }
                    $i++;

                    $outString .= "<strong>{$count((array)$v)}</strong>)<strong>(</strong></div>\n<span class=\"print-icon icon-hide\"></span></dt>\n";
                    $outString .= ltrim(self::_handleTypeOutput($v, true, false), '<dl>');
                } else {
                    $length_html = '';

                    if ($v === null) {
                        $v = '(null)';
                    } else if ($v === false) {
                        $v = '(false)';
                    } else if ($v === true) {
                        $v = '(true)';
                    } else {
                        $length = PrintHelper::strLength($v);
                        $length_html = "(<span class=\"general-print-color-g\">length:</span>{$length})";
                        $vType === 'string' && $v = "\"{$html($v,ENT_QUOTES)}\"";
                    }

                    $outString .= "<div class=\"array-value\"> &rArr; {$vType} <span class=\"general-print-color-r\">{$v}</span> {$length_html} </div></dt>" . PHP_EOL . "</dl>";
                }
            }//--endforeach--

            $endTab = substr($tab, 0, -($i - 1));
            $outString .= "\n</dd><!-- /.general-print-ar-content -->\n</dl>\n<dl><dt><strong>$endTab)</strong></dt>";
        } else if (is_object($data)) {
            // $outString .= PrintHelper::getSystemPrintData($data);
            $outString .= '<!-- .general-print-ar-content -->' . PHP_EOL . '<dd class="general-print-ar-content">';
            $outString .= PrintHelper::getSystemPrintData($data);
            $outString .= "\n</dd><!-- /.general-print-ar-content -->\n</dl>\n<dl><dt><strong>  )</strong></dt>";
        } else if (is_resource($data)) {
            if (($dataType = get_resource_type($data)) === 'stream' and $meta = stream_get_meta_data($data)) {

                if (isset($meta['uri'])) {
                    $file = $meta['uri'];
                    $resourceString = "Resource ({$dataType}) {$html( $file, ENT_QUOTES)}";
                } else {
                    $resourceString = "Resource ({$dataType})";
                }

            } else {
                $resourceString = "Resource ({$dataType})";
            }

            $outString .= sprintf($usualString, $resourceString);
        } else {
            $length = null;

            if ($data === false) $data = 'false';
            else if ($data === true) $data = 'true';
            else if ($data === null) $data = 'null';
            else $length = PrintHelper::strLength($data);// float integer string

            $dataType === 'string' && $data = "\"{$html($data,ENT_QUOTES)}\"";

            if ($length === null)
                $lengthString = '';
            else
                $lengthString = "(<span class=\"general-print-color-g\">length:</span>{$length})";

            $outString .= sprintf($usualString, "{$dataType} <span class=\"general-print-color-r\">{$data}</span> {$lengthString}");
        }

        return $outString . '</dl>' . PHP_EOL;
    }
520544
public static function part($str, $i, $delimiter, $default = null)
    {
        $parts = explode($delimiter, $str);

        return isset($parts[$i])
            ? $parts[$i]
            : $default;
    }
100456
public function handleDelimiter(string $data, string $delimiter = ',', string $assignment = '=')
    {
        if (strpos($data, $delimiter) !== false) {
            return $this->getParams(explode($delimiter, $data), $assignment);
        }

        return $this->handleAssignment($data);
    }
1075754
public function sentence($string, $delimiter = ' ', $option = \PINYIN_NO_TONE)
    {
        if (\is_int($delimiter)) {
            list($option, $delimiter) = array($delimiter, ' ');
        }

        return implode($delimiter, $this->convert($string, $option | \PINYIN_KEEP_PUNCTUATION | \PINYIN_KEEP_ENGLISH | \PINYIN_KEEP_NUMBER));
    }
771938
public static function getVendorPrefixRegExp($delimiter = null)
    {
        $vendorPrefixValues = self::getVendorPrefixValues();
        foreach ($vendorPrefixValues as $vendorPrefixKey => $vendorPrefixValue) {
            $vendorPrefixValues[$vendorPrefixKey] = preg_quote($vendorPrefixValue, $delimiter);
        }
        return implode('|', $vendorPrefixValues);
    }
515809
function snake( string $delimiter = '_' ) : SplString
    {
        $string = $this->__toString();
        if( !ctype_lower( $string ) ){
            $string = preg_replace( '/\s+/u', '', ucwords( $this->__toString() ) );
            $string = $this->setString( preg_replace( '/(.)(?=[A-Z])/u', '$1'.$delimiter, $string ) );
            $this->setString( $string );
            $this->lower();
        }
        return $this;
    }
1231758
public static function explodeTrim($str, $delimiter = ',')
    {
        if (is_string($delimiter)) {
            $str = trim(preg_replace('|\\s*(?:' . preg_quote($delimiter) . ')\\s*|', $delimiter, $str));
            return explode($delimiter, $str);
        }
        return $str;
    }
1191782
public static String concatStringWithDelimiter(String[] strings, String delimiter) {
        StringBuilder sbr = new StringBuilder();
        int size = strings.length;
        for (int i = 0; i < size - 1; i++) {
            sbr.append(strings[i]).append(delimiter);
        }
        sbr.append(strings[size - 1]);
        return sbr.toString();
    }
356319
public static function case2camel($string, $delimiter = '_')
    {
        $reg = '/' . $delimiter . '([a-z])/';
        return preg_replace_callback($reg, function ($mathes) use ($delimiter) {
            return trim(strtoupper($mathes[0]), $delimiter);
        }, $string);
    }
949295
function(scalar, delimiters, stringDelimiters, i, evaluate)
	{
		if ( delimiters == undefined ) delimiters = null;
		if ( stringDelimiters == undefined ) stringDelimiters = ['"', "'"];
		if ( i == undefined ) i = 0;
		if ( evaluate == undefined ) evaluate = true;
		
		var output = null;
		var pos = null;
		var matches = null;
		
		if ( this.inArray(scalar[i], stringDelimiters) )
		{
			// quoted scalar
			output = this.parseQuotedScalar(scalar, i);
			i = this.i;
			if (null !== delimiters) {
				var tmp = scalar.substr(i).replace(/^\s+/, '');
				if (!this.inArray(tmp.charAt(0), delimiters)) {
					throw new YamlParseException('Unexpected characters ('+scalar.substr(i)+').');
				}
			}
		}
		else
		{
			// "normal" string
			if ( !delimiters )
			{
				output = (scalar+'').substring(i);
				
				i += output.length;

				// remove comments
				pos = output.indexOf(' #');
				if ( pos != -1 )
				{
					output = output.substr(0, pos).replace(/\s+$/g,'');
				}
			}
			else if ( matches = new RegExp('^(.+?)('+delimiters.join('|')+')').exec((scalar+'').substring(i)) )
			{
				output = matches[1];
				i += output.length;
			}
			else
			{
				throw new YamlParseException('Malformed inline YAML string ('+scalar+').');
			}
			output = evaluate ? this.evaluateScalar(output) : output;
		}

		this.i = i;
		
		return output;
	}
706883
public static function machine($str, $separator = '_')
    {
        $out = strtolower($str);
        $out = preg_replace('/[^a-z0-9' . $separator . ']/', $separator, $out);
        $out = preg_replace('/' . $separator . '{2,}/', $separator, $out);
        $out = preg_replace('/^' . $separator . '/', '', $out);
        $out = preg_replace('/' . $separator . '$/', '', $out);
        return $out;
    }
145141
public function truncate($string, $length, $alignment = null, $delimString = null)
    {
        $alignment = $alignment === null ? 'left' : $alignment;
        $delimString = $delimString === null ? '...' : $delimString;
        $delimLen = strlen($delimString);

        if (!in_array($alignment, ['left', 'right'], true)) {
            throw new \InvalidArgumentException(
                'Alignment must either be "left" or "right"'
            );
        }

        if ($delimLen > $length) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Delimiter length "%s" cannot be greater than truncate length "%s"',
                    $delimLen,
                    $length
                )
            );
        }

        if (strlen($string) > $length) {
            $offset = $length - $delimLen;
            if ('left' === $alignment) {
                $string = substr($string, 0, $offset).$delimString;
            } else {
                $string = $delimString.substr($string, strlen($string) - $offset);
            }
        }

        return $string;
    }
122124
public static function snake($str, $delimiter = '_')
    {
        $str = preg_replace('/\s+/u', $delimiter, $str);

        $str = static::lower(preg_replace_callback('/([A-Z])/u', function ($math) use ($delimiter) {
            return $delimiter.static::lower($math[1]);
        }, $str));

        return trim(preg_replace('/'.$delimiter.'{2,}/', $delimiter, $str), $delimiter);
    }