Chris@0: data = $data; Chris@0: $this->responseParts = $this->createResponseParts($responseParts); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Creates an array of Response objects from a given response array Chris@0: * @param $responseParts Chris@0: * @return array Chris@0: */ Chris@0: protected function createResponseParts($responseParts) { Chris@0: if ($responseParts === null) { Chris@0: return array(); Chris@0: } Chris@0: $responses = array(); Chris@0: foreach ($responseParts as $responsePart) { Chris@0: $responses[] = new Response($responsePart); Chris@0: } Chris@0: return $responses; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return array Chris@0: */ Chris@0: public function getResponseParts() { Chris@0: return $this->responseParts; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param array $responseParts Chris@0: */ Chris@0: public function setResponseParts($responseParts) { Chris@0: $this->responseParts = $responseParts; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the url where the request is going to be made Chris@0: * @return string Chris@0: */ Chris@0: public function getUrl() { Chris@0: //TODO: add isset maybe? Chris@0: return $this->data['url']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the request method Chris@0: * @return string Chris@0: */ Chris@0: public function getMethod() { Chris@0: return $this->data['method']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the request headers Chris@0: * @return array Chris@0: */ Chris@0: public function getHeaders() { Chris@0: //TODO: Check if the data is actually an array, else make it array and see implications Chris@0: return $this->data['headers']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns if exists the request time Chris@0: * @return \DateTime Chris@0: */ Chris@0: public function getTime() { Chris@0: if (isset($this->data['time'])) { Chris@0: $requestTime = new \DateTime(); Chris@0: //TODO: fix the microseconds to miliseconds Chris@0: $requestTime->createFromFormat("Y-m-dTH:i:s.uZ", $this->data["time"]); Chris@0: return $requestTime; Chris@0: } Chris@0: return null; Chris@0: } Chris@0: Chris@0: }