public static function decode(string $arg)
    {
        $s = $arg;
        $s = str_replace('-', '+', $s);
        $s = str_replace('_', '/', $s);

        switch (strlen($s) % 4) {
            case 0:
                break;
            case 2:
                $s .= "==";
                break;
            case 3:
                $s .= "=";
                break;
            default:
                throw new \Exception("Illegal base64url string!");
        }

        return base64_decode($s);
    }