Convert to decimal string

@param  string $input
@param  string $fromBase
@return string
@access protected
434100
protected static function toBase10(
        /*# string */ $input,
        /*# string */ $fromBase
    )/*# string */ {
        $len = strlen($fromBase);
        $res = '0';
        foreach (str_split($input) as $char) {
            $res = bcadd((int) strpos($fromBase, $char), bcmul($res, $len));
        }
        return $res;
    }
1287519
public static function convert($input, $from, $to)
    {
        if (!method_exists(self::class, $to)) {
            return $input;
        }
        
        if (in_array($from, ['camel', 'pascal'])) {
            $converted = self::$from($input);
            $converted = preg_replace('/([a-z])([A-Z])/', '$1 $2', $converted);
            $converted = preg_replace('/(\D)?(\d+)(\D)?/', '$1 $2 $3', $converted);
            return self::$to($converted);
        }
        
        if (method_exists(self::class, $from)) {
            return self::$to(self::$from($input));
        }
        
        return self::$to($input);
    }
812149
private function stringToUtf($input)
    {
        if (is_array($input)) {
            $temp = array();
            foreach ($input as $key => $value) {
                $temp[$this->stringToUtf($key)] = $this->stringToUtf($value);
            }
            $input = $temp;
        } elseif (is_string($input)) {
            $input = iconv('iso-8859-15', 'utf-8', $input);
        }

        return $input;
    }
1318598
public function convert($value, $from, $to, $decimals = 2)
    {
        return (float) $this->from($value, $from)->to($to, $decimals, !empty($decimals));
    }
271805
public static function fromString($input, $start = 0, $end = null)
	{
		return self::appendFromString(self::builder(), $input, $start, $end);
	}
622852
public static function convert($string, $from = null, $to = self::ENCODING)
    {
        return mb_convert_encoding($string, $to, $from ? $from : static::detectEncoding($string));
    }
1165661
private static function parseFromFormat(string $input, string $format)
    {
        $parsedOrNull = null;

        if (($value = DateTimeImmutable::createFromFormat($format, $input)) !== false) {
            $parsedOrNull = $value;
        }

        return $parsedOrNull;
    }
425745
private function convertDate($time, $from, $format = "Y-m-d") {
            return \AsyncWeb\Date\Time::ConvertDate($time, $from, $format);
        }
124684
public static function toFloat($input = false) {

        if ($input && Validate::isNumber($input)) {

            $float = (float) $input;
            if (Validate::isFloat($float)) {

                return $float;
            }
        }

        return false;
    }
273887
public static function parseURL($input, self $base = null, $encodingOverride = null)
    {
        return self::parseBasicURL($input, $base, $encodingOverride);
    }
485730
public static function fromString($number)
    {
        $decimalSeparatorPosition = strpos($number, '.');
        if ($decimalSeparatorPosition === false) {
            return new self($number, '');
        }

        return new self(
            substr($number, 0, $decimalSeparatorPosition),
            rtrim(substr($number, $decimalSeparatorPosition + 1), '0')
        );
    }
971824
public static function decimalToAlphanumeric($number, $base = 64, $index = false)
    {
        if (!$base) {
            $base = strlen($index);
        } elseif (!$index) {
            $index = substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base);
        }

        $out = "";

        for ($i = floor(log10($number) / log10($base)); $i >= 0; $i--) { 
            $no = floor($num/pow($base, $i));
            $out = $out.substr($index, $no, 1);
            $number = $number - ($no * pow($base, $i));
        }
        return $out;
    }
1032269
public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)
    {
        $text     = PHPExcel_Calculation_Functions::flattenSingleValue($text);
        $fromText = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
        $toText   = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
        $instance = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));

        if ($instance == 0) {
            if (function_exists('mb_str_replace')) {
                return mb_str_replace($fromText, $toText, $text);
            } else {
                return str_replace($fromText, $toText, $text);
            }
        } else {
            $pos = -1;
            while ($instance > 0) {
                if (function_exists('mb_strpos')) {
                    $pos = mb_strpos($text, $fromText, $pos+1, 'UTF-8');
                } else {
                    $pos = strpos($text, $fromText, $pos+1);
                }
                if ($pos === false) {
                    break;
                }
                --$instance;
            }
            if ($pos !== false) {
                if (function_exists('mb_strlen')) {
                    return self::REPLACE($text, ++$pos, mb_strlen($fromText, 'UTF-8'), $toText);
                } else {
                    return self::REPLACE($text, ++$pos, strlen($fromText), $toText);
                }
            }
        }

        return $text;
    }
741830
protected static function bcDec2Base($number, $base, $baseChar)
    {
        $result    = '';
        $numberLen = strlen($number);
        // Now loop through each digit in the number
        for ($i = $numberLen - 1; $i >= 0; --$i) {
            $char = $number[$i]; // extract the last char from the number
            $ord  = strpos($baseChar, $char); // get the decimal value
            if ($ord === false || $ord > $base) {
                throw new \InvalidArgumentException('Argument number is invalid');
            }

            // Now convert the value+position to decimal
            $result = bcadd($result, bcmul($ord, bcpow($base, ($numberLen - $i - 1))));
        }

        return $result ? $result : '0';
    }
53186
public function convertFromNegative($input)
    {
        if (strpos('/*', $input[0]) !== false) {
            $input = substr($input, 1);
        }

        $input = strtr($input, static::NEGATIVE_CHARS, static::POSITIVE_CHARS);

        $res = $this->convertFromPositive($input);

        if (preg_match('/^0+$/', $res)) {
            return $res;
        }

        return '-' . $res;
    }
1349973
public static function BtoStr($input, $prec = self::BP_MB){
		$units = array("", "K", "M", "G", "T");
		
		
		for($i=0; $i < $prec; $i++)
		    $input = round($input / 1024,2);
		return $input.$units[$i]."B";
	}
324829
protected function convert($from, $to, $value)
    {
        return ($value * $this->getConversionRate($from)) / $this->getConversionRate($to);
    }