provider = $provider; } /** * {@inheritdoc} */ public function when(callable $onResolved) { if (null === $this->awaitable) { $provider = $this->provider; $this->provider = null; try { $this->awaitable = $provider(); if ($this->awaitable instanceof Awaitable) { $this->awaitable = new Success($this->awaitable); } } catch (\Throwable $exception) { $this->awaitable = new Failure($exception); } } $this->awaitable->when($onResolved); } }