1 | <?php |
||
23 | class MultiResponseHandlerTest implements MultiResponseHandlerInterface{ |
||
24 | |||
25 | /** |
||
26 | * @var \chillerlan\TinyCurl\MultiRequest |
||
27 | */ |
||
28 | protected $request; |
||
29 | |||
30 | public function __construct(MultiRequest $request){ |
||
31 | $this->request = $request; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * @param \chillerlan\TinyCurl\Response\ResponseInterface $response |
||
36 | * |
||
37 | * @return mixed |
||
38 | */ |
||
39 | public function handleResponse(ResponseInterface $response){ |
||
40 | $data = new stdClass; |
||
41 | $data->errorcode = $response->error->code; |
||
42 | $data->statuscode = $response->info->http_code; |
||
43 | $data->content_length_header = $response->headers->{'content-length'}; |
||
44 | $data->content_length_body = $response->body->length; |
||
45 | $data->content_type = $response->body->content_type; |
||
46 | $data->ids = array_column($response->json, 'id'); |
||
47 | |||
48 | sort($data->ids); |
||
49 | |||
50 | $this->request->addResponse($data); |
||
51 | } |
||
52 | |||
53 | } |
||
54 |