| @@ 261-273 (lines=13) @@ | ||
| 258 | * |
|
| 259 | * @return bool |
|
| 260 | */ |
|
| 261 | public function matches(\Closure $closure) |
|
| 262 | { |
|
| 263 | // Reduce the array to only booleans |
|
| 264 | $array = $this->each($closure); |
|
| 265 | ||
| 266 | // Check the results |
|
| 267 | if (count($array) === 0) { |
|
| 268 | return true; |
|
| 269 | } |
|
| 270 | $array = array_search(false, $array, false); |
|
| 271 | ||
| 272 | return is_bool($array); |
|
| 273 | } |
|
| 274 | ||
| 275 | /** |
|
| 276 | * Check if any item in an array matches a truth test. |
|
| @@ 282-294 (lines=13) @@ | ||
| 279 | * |
|
| 280 | * @return bool |
|
| 281 | */ |
|
| 282 | public function matchesAny(\Closure $closure) |
|
| 283 | { |
|
| 284 | // Reduce the array to only booleans |
|
| 285 | $array = $this->each($closure); |
|
| 286 | ||
| 287 | // Check the results |
|
| 288 | if (count($array) === 0) { |
|
| 289 | return true; |
|
| 290 | } |
|
| 291 | $array = array_search(true, $array, false); |
|
| 292 | ||
| 293 | return is_int($array); |
|
| 294 | } |
|
| 295 | ||
| 296 | /** |
|
| 297 | * Check if an item is in an array. |
|