src/includes/classes/Core/Utils/Base64.php
public function urlSafeEncode(string $string, array $url_unsafe_chars = ['+', '/'], array $url_safe_chars = ['-', '_'], string $trim_padding_chars = '='): string
    {
        if (!is_string($base64_url_safe = base64_encode($string))) {
            throw $this->c::issue('Base64 encoding failure.');
        }
        $base64_url_safe = str_replace($url_unsafe_chars, $url_safe_chars, $base64_url_safe);
        $base64_url_safe = isset($trim_padding_chars[0]) ? rtrim($base64_url_safe, $trim_padding_chars) : $base64_url_safe;

        return $base64_url_safe;
    }
public function urlSafeEncode(string $string, array $url_unsafe_chars = ['+', '/'], array $url_safe_chars = ['-', '_'], string $trim_padding_chars = '='): string
    {
        if (!is_string($base64_url_safe = base64_encode($string))) {
            throw $this->c::issue('Base64 encoding failure.');
        }
        $base64_url_safe = str_replace($url_unsafe_chars, $url_safe_chars, $base64_url_safe);
        $base64_url_safe = isset($trim_padding_chars[0]) ? rtrim($base64_url_safe, $trim_padding_chars) : $base64_url_safe;

        return $base64_url_safe;
    }
Base64 URL-safe encoding.

@since 150424 Initial release.

@param string $string             Input string to be base64 encoded.
@param array  $url_unsafe_chars   Optional array of un-safe characters. Defaults to: `['+', '/']`.
@param array  $url_safe_chars     Optional array of safe character replacements. Defaults to: `['-', '_']`.
@param string $trim_padding_chars Optional string of padding chars to right-trim. Defaults to: `=`.

@throws Exception If the call to `base64_encode()` fails.

@return string The base64 URL-safe encoded string.