# Helpers

Entries tagged with "Helpers".

Hidden Methods Beginner

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.

Collections Helpers
Hidden Methods Beginner

Str::squish()

Collapse all consecutive whitespace (including newlines and tabs) into a single space and trim the result.

Helpers
Blade Tricks Beginner

The @once Blade Directive

Render a block of template content only once per rendering cycle, even inside a loop.

Helpers
Unknown Classes Intermediate

The Sleep Class

A testable, expressive wrapper around PHP's sleep functions with a fluent API.

Testing Helpers
Unknown Classes Intermediate

The Lottery Class

Execute a callback with a given probability — perfect for sampling, feature flags, and A/B testing without external services.

Testing Helpers
Hidden Methods Intermediate

Number::pairs()

Split a numeric range into evenly sized chunks as start/end pairs — great for batch processing and pagination math.

Performance Helpers
Hidden Methods Beginner

The once() Helper

Memoize the result of an expensive expression so it only executes once per request, no matter how many times it is called.

Performance Helpers
Hidden Methods Beginner

Arr::undot()

Expand a flat dot-notation array back into a fully nested structure — the inverse of Arr::dot().

Collections Helpers
Hidden Methods Beginner

Str::password()

Generate a cryptographically secure random password with configurable length and character types.

Security Helpers
Hidden Methods Intermediate

Fluent Strings: whenContains()

Conditionally transform a string only if it contains a given substring — part of the powerful Stringable fluent API.

Helpers
Hidden Methods Beginner

The rescue() Helper

Execute a closure and swallow any exceptions, optionally returning a fallback value — a try/catch in a single expression.

Helpers Error Handling
Hidden Methods Beginner

Str::mask()

Mask a portion of a string with a repeated character — ideal for obscuring emails, phone numbers, or sensitive data.

Security Helpers