carno-php /
promise
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Sync |
||
| 4 | * User: moyo |
||
| 5 | * Date: 03/11/2017 |
||
| 6 | * Time: 11:55 AM |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Carno\Promise\Features; |
||
| 10 | |||
| 11 | use Carno\Promise\Promised; |
||
| 12 | use Throwable; |
||
| 13 | |||
| 14 | trait Sync |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @param Promised $next |
||
| 18 | * @return Promised |
||
| 19 | * @throws Throwable |
||
| 20 | */ |
||
| 21 | public function sync(Promised $next) : Promised |
||
| 22 | { |
||
| 23 | $this->then(static function (...$args) use ($next) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | $next->resolve(...$args); |
||
| 25 | }, static function (...$args) use ($next) { |
||
| 26 | $next->reject(...$args); |
||
| 27 | }); |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Promised $this |
||
| 31 | */ |
||
| 32 | |||
| 33 | return $this; |
||
| 34 | } |
||
| 35 | } |
||
| 36 |