0
|
1 <?php
|
|
2
|
|
3 namespace Abraham\TwitterOAuth;
|
|
4
|
|
5 /**
|
|
6 * The result of the most recent API request.
|
|
7 *
|
|
8 * @author Abraham Williams <[email protected]>
|
|
9 */
|
|
10 class Response
|
|
11 {
|
|
12 /** @var string|null API path from the most recent request */
|
|
13 private $apiPath;
|
|
14 /** @var int HTTP status code from the most recent request */
|
|
15 private $httpCode = 0;
|
|
16 /** @var array HTTP headers from the most recent request */
|
|
17 private $headers = [];
|
|
18 /** @var array|object Response body from the most recent request */
|
|
19 private $body = [];
|
|
20 /** @var array HTTP headers from the most recent request that start with X */
|
|
21 private $xHeaders = [];
|
|
22
|
|
23 /**
|
|
24 * @param string $apiPath
|
|
25 */
|
|
26 public function setApiPath($apiPath)
|
|
27 {
|
|
28 $this->apiPath = $apiPath;
|
|
29 }
|
|
30
|
|
31 /**
|
|
32 * @return string|null
|
|
33 */
|
|
34 public function getApiPath()
|
|
35 {
|
|
36 return $this->apiPath;
|
|
37 }
|
|
38
|
|
39 /**
|
|
40 * @param array|object $body
|
|
41 */
|
|
42 public function setBody($body)
|
|
43 {
|
|
44 $this->body = $body;
|
|
45 }
|
|
46
|
|
47 /**
|
|
48 * @return array|object|string
|
|
49 */
|
|
50 public function getBody()
|
|
51 {
|
|
52 return $this->body;
|
|
53 }
|
|
54
|
|
55 /**
|
|
56 * @param int $httpCode
|
|
57 */
|
|
58 public function setHttpCode($httpCode)
|
|
59 {
|
|
60 $this->httpCode = $httpCode;
|
|
61 }
|
|
62
|
|
63 /**
|
|
64 * @return int
|
|
65 */
|
|
66 public function getHttpCode()
|
|
67 {
|
|
68 return $this->httpCode;
|
|
69 }
|
|
70
|
|
71 /**
|
|
72 * @param array $headers
|
|
73 */
|
|
74 public function setHeaders(array $headers)
|
|
75 {
|
|
76 foreach ($headers as $key => $value) {
|
|
77 if (substr($key, 0, 1) == 'x') {
|
|
78 $this->xHeaders[$key] = $value;
|
|
79 }
|
|
80 }
|
|
81 $this->headers = $headers;
|
|
82 }
|
|
83
|
|
84 /**
|
|
85 * @return array
|
|
86 */
|
|
87 public function getsHeaders()
|
|
88 {
|
|
89 return $this->headers;
|
|
90 }
|
|
91
|
|
92 /**
|
|
93 * @param array $xHeaders
|
|
94 */
|
|
95 public function setXHeaders(array $xHeaders = [])
|
|
96 {
|
|
97 $this->xHeaders = $xHeaders;
|
|
98 }
|
|
99
|
|
100 /**
|
|
101 * @return array
|
|
102 */
|
|
103 public function getXHeaders()
|
|
104 {
|
|
105 return $this->xHeaders;
|
|
106 }
|
|
107 }
|