conditions.php
Table of Contents
Functions
- conditions() : array<string|int, callable>
- Normalize a set of conditions into an array of callable functions.
Functions
conditions()
Normalize a set of conditions into an array of callable functions.
conditions([array<string|int, mixed>|callable|string|null $conditions = null ][, bool $throwable = false ]) : array<string|int, callable>
This helper accepts multiple forms of input (null, single callable, array of callables) and returns a consistent array of callable conditions. It is useful when you want to filter, validate, or compress data using multiple dynamic rules.
Parameters
- $conditions : array<string|int, mixed>|callable|string|null = null
-
The conditions to normalize. Can be:
- null: defaults to a single condition that checks for null values.
- callable: a single condition function.
- array: an array of callable functions.
- string: (optional) a single callable function name or expression.
- $throwable : bool = false
-
If true, invalid conditions will throw an InvalidArgumentException. If false, invalid conditions are silently ignored.
Tags
Return values
array<string|int, callable> —Array of callable conditions.