Helpers
final class Helpers
Helper functions for HTTP requests, responses and headers.
Constants
| internal StrictCookieName |
|
| deprecated STRICT_COOKIE_NAME |
|
Methods
Formats a date and time in the HTTP date format (RFC 7231), e.g. 'Mon, 23 Jan 1978 10:00:00 GMT'.
Converts an expiration value to the number of seconds from now (may be negative for the past).
Parses an HTTP quality-value list such as the Accept, Accept-Language or Accept-Encoding header into tokens mapped to their q-factor, ordered by descending preference. Tokens are lowercased and those explicitly rejected with q=0 are omitted.
Checks whether an IP address falls within a CIDR block (e.g. '192.168.1.0/24').
Sends the SameSite=Strict cookie used as a fallback for detecting same-site requests in browsers that don't support the Sec-Fetch-Site header (Safari < 16.4).
Details
at line 32
static string
formatDate(string|int|DateTimeInterface $time)
Formats a date and time in the HTTP date format (RFC 7231), e.g. 'Mon, 23 Jan 1978 10:00:00 GMT'.
at line 46
static int|null
expirationToSeconds(string|int|DateTimeInterface|null $expire)
Converts an expiration value to the number of seconds from now (may be negative for the past).
Integers (or numeric strings) are relative seconds; other strings ('20 minutes', '2024-01-01') and DateTimeInterface are absolute times. Null returns null.
at line 79
static array
parseQualityList(string $header)
Parses an HTTP quality-value list such as the Accept, Accept-Language or Accept-Encoding header into tokens mapped to their q-factor, ordered by descending preference. Tokens are lowercased and those explicitly rejected with q=0 are omitted.
at line 110
static bool
ipMatch(string $ip, string $mask)
deprecated
deprecated
Checks whether an IP address falls within a CIDR block (e.g. '192.168.1.0/24').