123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- declare(strict_types=1);
- namespace GuzzleHttp\Promise;
- final class Each
- {
-
- public static function of(
- $iterable,
- callable $onFulfilled = null,
- callable $onRejected = null
- ): PromiseInterface {
- return (new EachPromise($iterable, [
- 'fulfilled' => $onFulfilled,
- 'rejected' => $onRejected,
- ]))->promise();
- }
-
- public static function ofLimit(
- $iterable,
- $concurrency,
- callable $onFulfilled = null,
- callable $onRejected = null
- ): PromiseInterface {
- return (new EachPromise($iterable, [
- 'fulfilled' => $onFulfilled,
- 'rejected' => $onRejected,
- 'concurrency' => $concurrency,
- ]))->promise();
- }
-
- public static function ofLimitAll(
- $iterable,
- $concurrency,
- callable $onFulfilled = null
- ): PromiseInterface {
- return self::ofLimit(
- $iterable,
- $concurrency,
- $onFulfilled,
- function ($reason, $idx, PromiseInterface $aggregate): void {
- $aggregate->reject($reason);
- }
- );
- }
- }
|