1 <?php
2 3 4 5 6 7 8 9
10
11 namespace triagens\ArangoDb;
12
13 14 15 16 17 18 19
20 class TraceResponse
21 {
22 23 24 25 26
27 private $_headers = [];
28
29 30 31 32 33
34 private $_httpCode;
35
36 37 38 39 40
41 private $_body;
42
43 44 45 46 47
48 private $_type = 'response';
49
50 51 52 53 54
55 private $_timeTaken;
56
57 58 59 60 61
62 private $_httpCodeDefinitions = [
63 100 => 'Continue',
64 101 => 'Switching Protocols',
65 200 => 'OK',
66 201 => 'Created',
67 202 => 'Accepted',
68 203 => 'Non-Authoritative Information',
69 204 => 'No Content',
70 205 => 'Reset Content',
71 206 => 'Partial Content',
72 300 => 'Multiple Choices',
73 301 => 'Moved Permanently',
74 302 => 'Found',
75 303 => 'See Other',
76 304 => 'Not Modified',
77 305 => 'Use Proxy',
78 307 => 'Temporary Redirect',
79 400 => 'Bad Request',
80 401 => 'Unauthorized',
81 402 => 'Payment Required',
82 403 => 'Forbidden',
83 404 => 'Not Found',
84 405 => 'Method Not Allowed',
85 406 => 'Not Acceptable',
86 407 => 'Proxy Authentication Required',
87 408 => 'Request Timeout',
88 409 => 'Conflict',
89 410 => 'Gone',
90 411 => 'Length Required',
91 412 => 'Precondition Failed',
92 413 => 'Request Entity Too Large',
93 414 => 'Request-URI Too Long',
94 415 => 'Unsupported Media Type',
95 416 => 'Requested Range Not Satisfiable',
96 417 => 'Expectation Failed',
97 418 => 'I\'m a teapot',
98 500 => 'Internal Server Error',
99 501 => 'Not Implemented',
100 502 => 'Bad Gateway',
101 503 => 'Service Unavailable',
102 504 => 'Gateway Timeout',
103 505 => 'HTTP Version Not Supported',
104 ];
105
106 107 108 109 110 111 112 113
114 public function __construct($headers, $httpCode, $body, $timeTaken)
115 {
116 $this->_headers = $headers;
117 $this->_httpCode = $httpCode;
118 $this->_body = $body;
119 $this->_timeTaken = $timeTaken;
120 }
121
122 123 124 125 126
127 public function getHeaders()
128 {
129 return $this->_headers;
130 }
131
132 133 134 135 136
137 public function getHttpCode()
138 {
139 return $this->_httpCode;
140 }
141
142 143 144 145 146 147
148 public function getHttpCodeDefinition()
149 {
150 if (!isset($this->_httpCodeDefinitions[$this->getHttpCode()])) {
151 throw new ClientException('Invalid http code provided.');
152 }
153
154 return $this->_httpCodeDefinitions[$this->getHttpCode()];
155 }
156
157 158 159 160 161
162 public function getBody()
163 {
164 return $this->_body;
165 }
166
167 168 169 170 171
172 public function getType()
173 {
174 return $this->_type;
175 }
176
177 178 179
180 public function getTimeTaken()
181 {
182 return $this->_timeTaken;
183 }
184 }
185