public static function convertToBase10($number, $fromBase)
    {
        $number = (string)ceil(static::getPlainNumber($number));

        if ($fromBase == 10) {
            return $number;
        } elseif ($fromBase < 2 || $fromBase > 32) {
            throw new InvalidArgumentException(sprintf(
                'Base %d is unsupported, should be between 2 and 32.',
                $fromBase
            ));
        }

        $result = '0';
        $chars = self::BASE32_ALPHABET;

        for ($i = 0, $len = strlen($number); $i < $len; $i++) {
            $index = strpos($chars, $number[$i]);

            if ($index >= $fromBase) {
                throw new RuntimeException(sprintf(
                    'The digit %s in the number %s is an invalid digit for base-%s.',
                    $chars[$index],
                    $number,
                    $fromBase
                ));
            }

            $result = bcmul($result, $fromBase);
            $result = bcadd($result, strpos($chars, $number[$i]));
        }

        return $result;
    }