Comparisons\groupAnd()

higher-order predicate variadic returns Closure returns bool pure
...(T → bool) → (T → bool)
At a glance — AND-combinator for predicates. See also all (alias).

Creates a predicate Closure that is true only when every bound predicate returns true for the input value.

/**
  * @param callable(mixed):bool ...$callables
  * @return Closure(mixed):bool
  */
Comparisons\groupAnd(callable ...$callables): Closure

Returned Closure

When Comparisons\groupAnd() is called, it returns the following Closure which can be used like a regular function.

/**
  * @param mixed $value
  * @return bool
  */
$function ($value): bool

Examples

Partial Application

This can be used to create a simple closure which can be used as a regular function.

$adultString = Comparisons\groupAnd(
  'is_string',
  fn($s) => strlen($s) >= 18
);

var_dump($adultString('hello world world world')); // true
var_dump($adultString('short'));                    // false
var_dump($adultString(12345678901234567890));       // false  (not string)

Details

Comparisons Functions

Releated Combinators Functions