Comparisons\notEmpty()

predicate returns bool pure
mixed → bool
At a glance — Direct call — no curry. Wraps the inverse of empty() for use as a callback.

Direct predicate — returns true when the value is not empty in PHP's empty() sense.

/**
  * @param mixed $value
  * @return bool
  */
Comparisons\notEmpty($value): bool

Examples

Partial Application

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

var_dump(Comparisons\notEmpty('hello'));   // true
var_dump(Comparisons\notEmpty(''));        // false
var_dump(Comparisons\notEmpty([]));        // false
var_dump(Comparisons\notEmpty(0));         // false

// As a callback.
$populated = array_filter(
  ['a', '', 'b', 0, 'c'],
  'PinkCrab\FunctionConstructors\Comparisons\notEmpty'
);

print_r($populated); // ['a', 'b', 'c']

Details

Comparisons Functions

Releated Truthiness Functions