The tap() Helper
Call a closure on a value and return the value, not the closure result. Perfect for chaining side-effects without breaking a fluent chain.
Entries tagged with "Helpers".
Call a closure on a value and return the value, not the closure result. Perfect for chaining side-effects without breaking a fluent chain.
Collapse all consecutive whitespace (including newlines and tabs) into a single space and trim the result.
Render a block of template content only once per rendering cycle, even inside a loop.
A testable, expressive wrapper around PHP's sleep functions with a fluent API.
Execute a callback with a given probability — perfect for sampling, feature flags, and A/B testing without external services.
Split a numeric range into evenly sized chunks as start/end pairs — great for batch processing and pagination math.
Memoize the result of an expensive expression so it only executes once per request, no matter how many times it is called.
Expand a flat dot-notation array back into a fully nested structure — the inverse of Arr::dot().
Generate a cryptographically secure random password with configurable length and character types.
Conditionally transform a string only if it contains a given substring — part of the powerful Stringable fluent API.
Execute a closure and swallow any exceptions, optionally returning a fallback value — a try/catch in a single expression.
Mask a portion of a string with a repeated character — ideal for obscuring emails, phone numbers, or sensitive data.