Decode the safeBase64Encode() of the string values

@see safeBase64Encode()

@param  string $string
@return string
514458
public static function safeBase64Decode($string)
    {
        $data = str_replace(['-', '_'], ['+', '/'], $string);
        $mod4 = strlen($data) % 4;
        if ($mod4) {
            $data .= substr('====', $mod4);
        }
        return base64_decode($data);
    }
749879
public static function base64Encode($string = '')
    {
        if (is_array($string) || is_object($string)) {
            $type   = gettype($string);
            $caller =  next(debug_backtrace());
            $error['line']  = $caller['line'];
            $error['file']  = strip_tags($caller['file']);
            trigger_error(
                "base64Encode() expects parameter 1 to be string, "
                . $type
                . " given in <b>{$error['file']}</b> on line <b>{$error['file']}</b><br />\n",
                E_USER_ERROR
            );

            return false;
        }

        /**
         * Use Internal
         */
        if (function_exists('base64_encode')) {
            return base64_encode($string);
        }
        if (strlen($string) <= 0) {
            return '';
        }

        $binval  = static::str2bin($string);
        $final = "";
        $start = 0;
        while ($start < strlen($binval)) {
            if (strlen(substr($binval, $start)) < 6) {
                $binval .= str_repeat("0", 6 - strlen(substr($binval, $start)));
            }
            $tmp = bindec(substr($binval, $start, 6));
            if ($tmp < 26) {
                $final .= chr($tmp + 65);
            } elseif ($tmp > 25 && $tmp < 52) {
                $final .= chr($tmp + 71);
            } elseif ($tmp == 62) {
                $final .= "+";
            } elseif ($tmp == 63) {
                $final .= "/";
            } elseif (!$tmp) {
                $final .= "A";
            } else {
                $final .= chr($tmp - 4);
            }
            $start += 6;
        }
        if (strlen($final) % 4 > 0) {
            $final .= str_repeat("=", 4 - strlen($final) % 4);
        }

        return $final;
    }
837040
private static function encodeString($string)
    {
        // Note:
        // strlen() returns the number of bytes rather than the number of characters in a string.

        // Differentiate on the string length.
        if (strlen($string) < 32) {
            // fixstr
            $prefix = bindec(101) * 32 + strlen($string);
        } elseif (strlen($string) < pow(2, 8)) {
            // str 8
            $prefix = 0xd9 * 256 + strlen($string);
        } elseif (strlen($string) < pow(2, 16)) {
            // str 16
            $prefix = 0xda * 256 * 256 + strlen($string);
        } elseif (strlen($string) < pow(2, 32)) {
            // str 32
            $prefix = 0xdb * 256 * 256 * 256 * 256 + strlen($string);
        } else {
            throw new UnencodeableException('String to be encoded is too long', 4);
        }

        // Encode it and concatenate with all bytes of the string value.
        return pack('H*', dechex($prefix)) . $string;
    }
693938
public static function decode($string)
    {
        $result = json_decode($string, true);

        switch (json_last_error()) {
            case JSON_ERROR_NONE:
                return $result;

            case JSON_ERROR_DEPTH:
                throw new \Exception("Maximum stack depth exceeded");

            case JSON_ERROR_STATE_MISMATCH:
                throw new \Exception("Underflow or the modes mismatch");

            case JSON_ERROR_CTRL_CHAR:
                throw new \Exception("Unexpected control character found");

            case JSON_ERROR_SYNTAX:
                throw new \Exception("Syntax error, malformed JSON");

            case JSON_ERROR_UTF8:
                throw new \Exception("Malformed UTF-8 characters, possibly incorrectly encoded");
            
            default:
                throw new \Exception("Unknown error on JSON file");
        }
    }
262130
public function encodeHashOfString($string)
    {

        $salt = $this->getServiceContainer()->getParameter('secret');

        $key = substr(base64_encode($salt), 0, 30);

        $options = array(
            'cost' => 13,
            'salt' => $key
        );

        $hash = hash('sha512', password_hash($string, PASSWORD_BCRYPT, $options));

        return $hash;
    }
1034082
public static function decode($string)
    {
        if (! is_string($string)) {
            throw new JsonException('Json decode parameter must be a string');
        }

        $result = json_decode($string, true);

        if ($result === null) {
            throw new JsonException('Json decode error');
        }
        return $result;
    }
1243973
private function unserialize($string)
    {
        if (false === $string || null === $string || '' === $string) {
            throw new \InvalidArgumentException('Unable to unserialize value.');
        }
        set_error_handler(
            function () {
                restore_error_handler();
                throw new \InvalidArgumentException('Unable to unserialize value, string is corrupted.');
            },
            E_NOTICE
        );
        $result = unserialize($string);
        restore_error_handler();

        return $result;
    }
815556
public static function decode(string $string)
    {
        $content = json_decode($string, true);

        self::throwOnError();

        return $content;
    }
446468
public static function decodeToInteger($string)
    {
        $stringLength = strlen($string);

        $baseLength = strlen(static::$chars);

        $id = 0;

        for($i = 0; $i < $stringLength; $i++){

            $pos = strpos(static::$chars, $string[$i]);

            $id = ($id * $baseLength) + $pos;

        }

        return $id;
    }
1321135
public static function encode(
    /*string*/ $string,
    /*boolean*/ $oneLine = true
  ) {
    if(!self::isEncoded($string)) {
      $string = base64_encode($string);
    }
    if($string && $oneLine) {
      $string = str_replace(["\r", "\n"], '', $string);
    }
    return $string;
  }
66870
protected function decodeConfiguration($string)
    {
        $config = [];
        $directives = explode($this->directiveSeparator, $string);
        foreach ($directives as $directive) {
            $parts = array_filter(explode($this->sourceSeparator, $directive));
            $key = trim(array_shift($parts));
            $config[$key] = $parts;
        }

        return $config;
    }
1007223
public static function encode(String $string) : String
    {
        $secBadChars = self::$scriptBadChars;

        if( ! empty($secBadChars) )
        {
            foreach( $secBadChars as $badChar => $changeChar )
            {
                if( is_numeric($badChar) )
                {
                    $badChar = $changeChar;
                    $changeChar = '';
                }

                $badChar = trim($badChar, '/');

                $string = preg_replace('/'.$badChar.'/xi', $changeChar, $string);
            }
        }

        return $string;
    }
1107345
public function decryptBase64($text, $key = null, $safe = false)
    {
        if ($safe === true) {
            return $this->decrypt(base64_decode(strtr($text, '-_', '+/')), $key);
        }

        return $this->decrypt(base64_decode($text), $key);
    }
236679
public function decrypt($string, $key = null)
    {
        if (null === $key) {
            $key = $this->getEncryptKey();
        }

        $cipherText = base64_decode($string);
        $ivSize     = $this->getMsCryptIvSize();

        $ivDec = substr($cipherText, 0, $ivSize);

        $cipherText = substr($cipherText, $ivSize);

        return mcrypt_decrypt(
            $this->getMcryptCipher(),
            $key,
            $cipherText,
            $this->getMcryptMode(),
            $ivDec
        );
    }
347951
public function encodeReversibleString($string)
    {

        $salt = $this->getSecretAppString();

        $key = substr(base64_encode($salt), 0, 50);
        $iv = '12345678';
        $cc = base64_encode(json_encode(array(
            'time' => strrev('' . time()),
            'key' => $string,
            'random' => rand(10000000, 99999999)
        )));

        $cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');

        mcrypt_generic_init($cipher, $key, $iv);
        $encrypted = mcrypt_generic($cipher, $cc);
        mcrypt_generic_deinit($cipher);

        return base64_encode($encrypted);
    }
1157031
public static function blazeEncrypt (string $string) : string
    {
        $cryptKey           = 'qJB0rGtIn5UB1xG03efyCp';
        return base64_encode(mcrypt_encrypt(
        	MCRYPT_RIJNDAEL_256, md5($cryptKey), $string, MCRYPT_MODE_CBC, md5(md5($cryptKey)))
        );
    }
97619
protected function encodeDate($string = '')
    {
        // maybe has to be rewritten for multibyte...
        $length        = strlen($string);
        $encodedString = '';

        for ($i = 0; $i < $length; ++$i) {
            $encodedString .= '\\'.$string[$i];
        }

        // return encoded string
        return $encodedString;
    }