|
@@ 363-373 (lines=11) @@
|
| 360 |
|
* @param mixed $object |
| 361 |
|
* @return bool |
| 362 |
|
*/ |
| 363 |
|
function satisfiesAll() { |
| 364 |
|
static $satisfiesAll = false; |
| 365 |
|
$satisfiesAll = $satisfiesAll ?: curry(function($predicates, $object) { |
| 366 |
|
$predicates = map(function($pair) { |
| 367 |
|
return satisfies($pair[1], $pair[0]); |
| 368 |
|
}, toPairs($predicates)); |
| 369 |
|
$predicates = apply(_f('all'), $predicates); |
| 370 |
|
return $predicates($object); |
| 371 |
|
}); |
| 372 |
|
return _apply($satisfiesAll, func_get_args()); |
| 373 |
|
} |
| 374 |
|
|
| 375 |
|
/** |
| 376 |
|
* Checks if a list of attribute/value of an object/array passes any of the given predicates. |
|
@@ 401-411 (lines=11) @@
|
| 398 |
|
* @param mixed $object |
| 399 |
|
* @return bool |
| 400 |
|
*/ |
| 401 |
|
function satisfiesAny() { |
| 402 |
|
static $satisfiesAny = false; |
| 403 |
|
$satisfiesAny = $satisfiesAny ?: curry(function($predicates, $object) { |
| 404 |
|
$predicates = map(function($pair) { |
| 405 |
|
return satisfies($pair[1], $pair[0]); |
| 406 |
|
}, toPairs($predicates)); |
| 407 |
|
$predicates = apply(_f('any'), $predicates); |
| 408 |
|
return $predicates($object); |
| 409 |
|
}); |
| 410 |
|
return _apply($satisfiesAny, func_get_args()); |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
/** |
| 414 |
|
* Converts an object or associative array to an array of [key, value] pairs. |