AsyncContext example


        }
    }

    /** * @param \SplObjectStorage<ResponseInterface, AsyncResponse>|null $asyncMap */
    private static function passthru(HttpClientInterface $client, self $r, ChunkInterface $chunk, \SplObjectStorage $asyncMap = null): \Generator
    {
        $r->stream = null;
        $response = $r->response;
        $context = new AsyncContext($r->passthru, $client$r->response, $r->info, $r->content, $r->offset);
        if (null === $stream = ($r->passthru)($chunk$context)) {
            if ($r->response === $response && (null !== $chunk->getError() || $chunk->isLast())) {
                throw new \LogicException('A chunk passthru cannot swallow the last chunk.');
            }

            return;
        }

        if (!$stream instanceof \Iterator) {
            throw new \LogicException(sprintf('A chunk passthru must return an "Iterator", "%s" returned.', get_debug_type($stream)));
        }
        
private function getContext($retryCount$method$url$statusCode): AsyncContext
    {
        $passthru = null;
        $info = [
            'retry_count' => $retryCount,
            'http_method' => $method,
            'url' => $url,
            'http_code' => $statusCode,
        ];
        $response = new MockResponse('', $info);

        return new AsyncContext($passthrunew MockHttpClient()$response$info, null, 0);
    }
}
Home | Imprint | This part of the site doesn't use cookies.