Fix bug in style changes for the Use cases on the live site.
[yaffs-website] / vendor / jcalderonzumba / gastonjs / src / NetworkTraffic / Response.php
1 <?php
2 namespace Zumba\GastonJS\NetworkTraffic;
3
4 /**
5  * Class Response
6  * @package Zumba\GastonJS\NetworkTraffic
7  */
8 class Response {
9   /** @var  array */
10   protected $data;
11
12   /**
13    * @param $data
14    */
15   public function __construct($data) {
16     $this->data = $data;
17   }
18
19   /**
20    * Gets Response url
21    * @return string
22    */
23   public function getUrl() {
24     return $this->data['url'];
25   }
26
27   /**
28    * Gets the response status code
29    * @return int
30    */
31   public function getStatus() {
32     return intval($this->data['status']);
33   }
34
35   /**
36    * Gets the status text of the response
37    * @return string
38    */
39   public function getStatusText() {
40     return $this->data['statusText'];
41   }
42
43   /**
44    * Gets the response headers
45    * @return array
46    */
47   public function getHeaders() {
48     return $this->data['headers'];
49   }
50
51   /**
52    * Get redirect url if response is a redirect
53    * @return string
54    */
55   public function getRedirectUrl() {
56     if (isset($this->data['redirectUrl']) && !empty($this->data['redirectUrl'])) {
57       return $this->data['redirectUrl'];
58     }
59     return null;
60   }
61
62   /**
63    * Returns the size of the response body
64    * @return int
65    */
66   public function getBodySize() {
67     if (isset($this->data['bodySize'])) {
68       return intval($this->data['bodySize']);
69     }
70     return 0;
71   }
72
73   /**
74    * Returns the content type of the response
75    * @return string
76    */
77   public function getContentType() {
78     if (isset($this->data['contentType'])) {
79       return $this->data['contentType'];
80     }
81     return null;
82   }
83
84   /**
85    * Returns if exists the response time
86    * @return \DateTime
87    */
88   public function getTime() {
89     if (isset($this->data['time'])) {
90       $requestTime = new \DateTime();
91       //TODO: fix the microseconds to miliseconds
92       $requestTime->createFromFormat("Y-m-dTH:i:s.uZ", $this->data["time"]);
93       return $requestTime;
94     }
95     return null;
96   }
97 }