| @@ 354-368 (lines=15) @@ | ||
| 351 | { |
|
| 352 | $map = $this->clear(); |
|
| 353 | ||
| 354 | foreach ($this->keys as $index => $key) { |
|
| 355 | $return = $function( |
|
| 356 | $key, |
|
| 357 | $this->values->get($index) |
|
| 358 | ); |
|
| 359 | ||
| 360 | if ($return instanceof Pair) { |
|
| 361 | $key = $return->key(); |
|
| 362 | $value = $return->value(); |
|
| 363 | } else { |
|
| 364 | $value = $return; |
|
| 365 | } |
|
| 366 | ||
| 367 | $map = $map->put($key, $value); |
|
| 368 | } |
|
| 369 | ||
| 370 | return $map; |
|
| 371 | } |
|
| @@ 465-476 (lines=12) @@ | ||
| 462 | $truthy = $this->clear(); |
|
| 463 | $falsy = $this->clear(); |
|
| 464 | ||
| 465 | foreach ($this->keys as $index => $key) { |
|
| 466 | $return = $predicate( |
|
| 467 | $key, |
|
| 468 | $value = $this->values->get($index) |
|
| 469 | ); |
|
| 470 | ||
| 471 | if ($return === true) { |
|
| 472 | $truthy = $truthy->put($key, $value); |
|
| 473 | } else { |
|
| 474 | $falsy = $falsy->put($key, $value); |
|
| 475 | } |
|
| 476 | } |
|
| 477 | ||
| 478 | return (new self('bool', MapInterface::class)) |
|
| 479 | ->put(true, $truthy) |
|