27 use IteratorAggregate;
45 protected $responses = [];
55 $this->batchRequest = $batchRequest;
61 parent::__construct($request, $body, $httpStatusCode, $headers);
64 $this->setResponses($responses);
74 return $this->responses;
85 $this->responses = [];
87 foreach ($responses
as $key => $graphResponse) {
88 $this->addResponse($key, $graphResponse);
100 $originalRequestName = isset($this->batchRequest[$key][
'name']) ? $this->batchRequest[$key][
'name'] : $key;
101 $originalRequest = isset($this->batchRequest[$key][
'request']) ? $this->batchRequest[$key][
'request'] :
null;
103 $httpResponseBody = isset($response[
'body']) ? $response[
'body'] :
null;
104 $httpResponseCode = isset($response[
'code']) ? $response[
'code'] :
null;
106 $httpResponseHeaders = isset($response[
'headers']) ? $this->normalizeBatchHeaders($response[
'headers']) : [];
121 return new ArrayIterator($this->responses);
129 $this->addResponse($offset, $value);
137 return isset($this->responses[$offset]);
145 unset($this->responses[$offset]);
153 return isset($this->responses[$offset]) ? $this->responses[$offset] :
null;
164 private function normalizeBatchHeaders(array $batchHeaders)
168 foreach ($batchHeaders
as $header) {
169 $headers[$header[
'name']] = $header[
'value'];