Payload
in package
FinalYes
URL-safe base64 payload helpers.
Port of upstream aiogram/utils/payload.py — encode_payload / decode_payload.
PHP does not provide a single-arg URL-safe base64 function, so we apply a
character map over the standard base64_encode / base64_decode:
+ → -, / → _ (encode direction)
- → +, _ → / (decode direction)
Trailing = padding characters are stripped on encode and restored on decode.
Table of Contents
Methods
- decode() : string
- Decode a URL-safe base64 string (padding is restored automatically).
- encode() : string
- Encode a string as URL-safe base64 (no padding).
- __construct() : mixed
Methods
decode()
Decode a URL-safe base64 string (padding is restored automatically).
public
static decode(string $payload[, null|callable(string): string $decoder = null ]) : string
Parameters
- $payload : string
- $decoder : null|callable(string): string = null
-
optional post-decoding step applied to the raw bytes after base64 decoding
Return values
stringencode()
Encode a string as URL-safe base64 (no padding).
public
static encode(string $payload[, null|callable(string): string $encoder = null ]) : string
Parameters
- $payload : string
- $encoder : null|callable(string): string = null
-
optional pre-encoding step applied to the raw UTF-8 bytes before base64
Return values
string__construct()
private
__construct() : mixed