3 namespace Zumba\GastonJS\NetworkTraffic;
7 * @package Zumba\GastonJS\NetworkTraffic
13 protected $responseParts;
18 * @param array $responseParts
20 public function __construct($data, $responseParts = null) {
22 $this->responseParts = $this->createResponseParts($responseParts);
26 * Creates an array of Response objects from a given response array
27 * @param $responseParts
30 protected function createResponseParts($responseParts) {
31 if ($responseParts === null) {
35 foreach ($responseParts as $responsePart) {
36 $responses[] = new Response($responsePart);
44 public function getResponseParts() {
45 return $this->responseParts;
49 * @param array $responseParts
51 public function setResponseParts($responseParts) {
52 $this->responseParts = $responseParts;
56 * Returns the url where the request is going to be made
59 public function getUrl() {
60 //TODO: add isset maybe?
61 return $this->data['url'];
65 * Returns the request method
68 public function getMethod() {
69 return $this->data['method'];
73 * Gets the request headers
76 public function getHeaders() {
77 //TODO: Check if the data is actually an array, else make it array and see implications
78 return $this->data['headers'];
82 * Returns if exists the request time
85 public function getTime() {
86 if (isset($this->data['time'])) {
87 $requestTime = new \DateTime();
88 //TODO: fix the microseconds to miliseconds
89 $requestTime->createFromFormat("Y-m-dTH:i:s.uZ", $this->data["time"]);