|
@@ 301-310 (lines=10) @@
|
| 298 |
|
* @param mixed $object |
| 299 |
|
* @return bool |
| 300 |
|
*/ |
| 301 |
|
function satisfiesAll() { |
| 302 |
|
$satisfiesAll = function($predicates, $object) { |
| 303 |
|
$predicates = map(function($pair) { |
| 304 |
|
return satisfies($pair[1], $pair[0]); |
| 305 |
|
}, toPairs($predicates)); |
| 306 |
|
$predicates = apply(_f('all'), $predicates); |
| 307 |
|
return $predicates($object); |
| 308 |
|
}; |
| 309 |
|
return apply(curry($satisfiesAll), func_get_args()); |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
/** |
| 313 |
|
* Checks if a list of attribute/value of an object/array passes any of the given predicates. |
|
@@ 342-351 (lines=10) @@
|
| 339 |
|
* @param mixed $object |
| 340 |
|
* @return bool |
| 341 |
|
*/ |
| 342 |
|
function satisfiesAny() { |
| 343 |
|
$satisfiesAny = function($predicates, $object) { |
| 344 |
|
$predicates = map(function($pair) { |
| 345 |
|
return satisfies($pair[1], $pair[0]); |
| 346 |
|
}, toPairs($predicates)); |
| 347 |
|
$predicates = apply(_f('any'), $predicates); |
| 348 |
|
return $predicates($object); |
| 349 |
|
}; |
| 350 |
|
return apply(curry($satisfiesAny), func_get_args()); |
| 351 |
|
} |
| 352 |
|
|
| 353 |
|
/** |
| 354 |
|
* Converts an object or associative array to an array of [key, value] pairs. |