解析 ECPay 回傳結果.

@author		https://www.ecpay.com.tw
@category	SDK_Misc
@param		string	$Feedback		回傳結果
@param		array	$FeedbackList	合法回傳參數
@param		string	$Separator		分隔符號
@return		array
@version		1.0.1012
336728
private function ParseFeedback($Feedback, $FeedbackList = ['RtnCode', 'RtnMsg'], $Separator = '|')
        {
            $Pieces = explode($Separator, $Feedback);
            $Feedback = [];
            // 回傳參數檢查
            if (count($Pieces) == count($FeedbackList)) {
                foreach ($FeedbackList as $Idx => $Name) {
                    $Feedback[$Name] = $Pieces[$Idx];
                }
            } else {
                $Feedback['ParseMsg'] = 'Unknown feedback : '.$Feedback;
            }

            return $Feedback;
        }
535625
public function split($separator)
    {
        $hash = new Hash(explode((string) $separator, (string) $this));

        return $hash->map(
            function ($value) {
                return new String($value);
            }
        );
    }
552987
public function sendLine($data, $separator = "\n")
  {
    $size = strlen($data);
    $pack = 4096;

    for($seek = 0 ;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $buff = substr($data, $seek, $pack);
      $seek = $seek+$pack;

      if($seek >= $size) $buff .= $separator;

      $this->send($buff);
    }
  }
1111396
public function split($separator, $limit = 0)
  {
    $parts = explode($separator, $this->string, ($limit) ? intval($limit) : $this->count());

    foreach($parts as $key => $val)
    {
      $parts[$key] = new self($val);
    }

    return $parts;
  }
1355547
public function removeDot(string $notation, string $separator = '.')
    {
        $args = explode($separator, $notation);

        if (count($args) === 0) {
            return $this;
        }

        $last = array_pop($args);

        $pointer = &$this->data;
        foreach ($args as $i => $step) {
            if (!isset($pointer[$step])
                || !is_array($pointer[$step])
            ) {
                $pointer[$step] = [];
            }

            $pointer = &$pointer[$step];
        }

        unset($pointer[$last]);

        return $this;
    }
1214976
public static function flattenArray(array $array, $separator = '_')
    {
        $resultArray = [];
        foreach ($array as $key => $val) {
            if (is_array($val)) {
                /* @noinspection AdditionOperationOnArraysInspection */
                $resultArray += self::prefixArray(self::flattenArray($val), $key, $separator);
            } else {
                $resultArray[$key] = $val;
            }
        }

        return $resultArray;
    }
1174628
public function getFolders($separator = null, $type = 0)
    {
        if(preg_match( '/^{.+}/', $this->mailbox, $matches)){
            $mailbox = $matches[0];
        }else{
            $mailbox = $this->mailbox;
        };

        $folders = imap_list($this->imap, $mailbox, "*");

        if ($type == 2) {
            return $folders;
        };
        if ($type == 1) {
            return str_replace($mailbox, "", $folders);
        };
        if ($type == 0) {
            $arrayRaw = str_replace($mailbox, "", $folders);
            if (!isset($separator)) {
                $separator = '.';
            };
            $arrayNew = [];
            foreach ($arrayRaw as $string) {
                $array = explode($separator, $string);
                $count = count($array);
                $count = $count-1;
                $cache = false;
                for($i=$count; $i>=0; $i--){
                    if($i == $count){
                        $cache = [$array[$i]=>[]];
                    }else{
                        $cache = [$array[$i] => $cache];
                    };
                };
                $arrayNew = array_merge_recursive($arrayNew, $cache);
            };
            return $arrayNew;
        }
        return null;
    }
1128503
public static <E> String listAsString(List<E> list, String separator) {

        StringBuffer string = new StringBuffer(128);
        Iterator<E> it = list.iterator();
        while (it.hasNext()) {
            string.append(it.next());
            if (it.hasNext()) {
                string.append(separator);
            }
        }
        return string.toString();
    }
953456
public function feedbacks($level = null)
    {
        if ($level !== null) {
            if (!is_string($level)) {
                throw new InvalidArgumentException('The feedback level must be a string');
            }

            $level = $this->resolveFeedbackLevel($level);

            $subset = [];
            foreach ($this->feedbacks as $item) {
                if ($item['level'] === $level) {
                    $subset[] = $item;
                }
            }

            return $subset;
        }

        return $this->feedbacks;
    }
477627
public function getJoinedMessage($separator = "\n")
    {
        $messages = $this->getDetailMessages();
        $array = array();
        foreach ($messages as $rules) {
            foreach ($rules as $options) {
                foreach ($options as $message) {
                    $array[] = $message;
                }
            }
        }
        return implode($separator, array_unique($array));
    }
559995
public function addMacAddressSeparator(string $str, string $separator = ':'): string
    {
        return join($separator, str_split(preg_replace('/[^a-f0-9]/i', '', $str), 2));
    }
410406
public function format_feedback($feedback, $grade = null) {
        $string = $feedback->feedback;
        if (!empty($grade)) {
            // Rewrite links to get the export working for 36, refer MDL-63488.
            $string = file_rewrite_pluginfile_urls(
                $feedback->feedback,
                'pluginfile.php',
                $grade->get_context()->id,
                GRADE_FILE_COMPONENT,
                GRADE_FEEDBACK_FILEAREA,
                $grade->id
            );
        }

        return strip_tags(format_text($string, $feedback->feedbackformat));
    }
461729
public function asArray(string $separator = self::ARRAY_SEPARATOR)
    {
        $this->checkDefaultType(function() { return is_array($this->default);}, 'array');
        return $this->default;
    }
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);
    }
393578
public static function merge(
        string $list1,
        string $list2,
        bool $sort,
        string $separator,
        string $tag = ''
    ): string {
        $items1 = self::explode($separator, $list1);
        $items2 = self::explode($separator, $list2);
        if (count($items2) > 0) {
            foreach ($items2 as $item) {
                if (!in_array($item, $items1)) {
                    $items1[] = $item;
                }
            }
        }
        if ($sort) {
            sort($items1);
        }
        return implode($separator, $items1);
    }
166229
public function toString($separator = null)
    {
        if (!is_null($separator)) {
            $this->_separator = $separator;
        }

        $this->_prepareData();
        return $this->__toString();
    }
647240
public function getDot(string $notation, string $separator = '.')
    {
        $args = explode($separator, $notation);

        if (count($args) == 0) {
            return null;
        }

        $last = array_pop($args);
        $pointer = &$this->data;

        foreach ($args as $step) {
            if (!isset($pointer[$step])) {
                return null;
            }

            $pointer = &$pointer[$step];
        }

        if (!isset($pointer[$last])) {
            return null;
        }

        return $pointer[$last];
    }