|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @abstract API client for Optimizely. |
|
4
|
|
|
* @author Oleg Krivtsov <[email protected]> |
|
5
|
|
|
* @date 14 November 2016 |
|
6
|
|
|
* @copyright (c) 2016, Web Marketing ROI |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace WebMarketingROI\OptimizelyPHP; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Contains parsed response from Optimizely API. |
|
12
|
|
|
*/ |
|
13
|
|
|
class Result |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* HTTP code. |
|
17
|
|
|
* @var integer |
|
18
|
|
|
*/ |
|
19
|
|
|
private $httpCode; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Payload. |
|
23
|
|
|
* @var mixed |
|
24
|
|
|
*/ |
|
25
|
|
|
private $payload = null; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Previous page number (or null). |
|
29
|
|
|
* @var integer|null |
|
30
|
|
|
*/ |
|
31
|
|
|
private $prevPage = null; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Next page number (or null). |
|
35
|
|
|
* @var integer|null |
|
36
|
|
|
*/ |
|
37
|
|
|
private $nextPage = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Last page number |
|
41
|
|
|
* @var integer|null |
|
42
|
|
|
*/ |
|
43
|
|
|
private $lastPage = null; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* The limit for this endpoint |
|
47
|
|
|
* @var integer |
|
48
|
|
|
*/ |
|
49
|
|
|
private $rateLimit; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* The amount of calls remaining for this endpoint |
|
53
|
|
|
* @var integer |
|
54
|
|
|
*/ |
|
55
|
|
|
private $rateLimitRemaining; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* The X-RateLimit-Reset header provides a Unix UTC timestamp, letting you |
|
59
|
|
|
* know the exact time that your fresh new rate limit kicks in. |
|
60
|
|
|
* @var string |
|
61
|
|
|
*/ |
|
62
|
|
|
private $rateLimitReset; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Decoded JSON response data. |
|
66
|
|
|
* @var array |
|
67
|
|
|
*/ |
|
68
|
|
|
private $decodedJsonData = null; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Constructor. |
|
72
|
|
|
* @param array $decodedJsonData |
|
73
|
|
|
* @param string $rawHttpResponseData |
|
|
|
|
|
|
74
|
|
|
* @param array[string] $rawHttpResponseHeaders |
|
|
|
|
|
|
75
|
|
|
*/ |
|
76
|
31 |
|
public function __construct($decodedJsonData, $httpCode) |
|
77
|
|
|
{ |
|
78
|
31 |
|
$this->decodedJsonData = $decodedJsonData; |
|
79
|
31 |
|
$this->httpCode = $httpCode; |
|
80
|
31 |
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Return HTTP response code. |
|
84
|
|
|
* @return integer |
|
85
|
|
|
*/ |
|
86
|
3 |
|
public function getHttpCode() |
|
87
|
|
|
{ |
|
88
|
3 |
|
return $this->httpCode; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Set HTTP response code. |
|
93
|
|
|
* @param integer $code |
|
|
|
|
|
|
94
|
|
|
*/ |
|
95
|
|
|
public function setHttpCode($httpCode) |
|
96
|
|
|
{ |
|
97
|
|
|
$this->httpCode = $httpCode; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Return payload. |
|
102
|
|
|
* @return mixed |
|
103
|
|
|
*/ |
|
104
|
29 |
|
public function getPayload() |
|
105
|
|
|
{ |
|
106
|
29 |
|
return $this->payload; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Set payload (parsed and wrapped response data). |
|
111
|
|
|
* @param mixed $payload |
|
112
|
|
|
*/ |
|
113
|
28 |
|
public function setPayload($payload) |
|
114
|
|
|
{ |
|
115
|
28 |
|
$this->payload = $payload; |
|
116
|
28 |
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Return decoded JSON data. |
|
120
|
|
|
* @return array |
|
121
|
|
|
*/ |
|
122
|
28 |
|
public function getDecodedJsonData() |
|
123
|
|
|
{ |
|
124
|
28 |
|
return $this->decodedJsonData; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Set decoded JSON data. |
|
129
|
|
|
* @param array $decodedJsonData |
|
130
|
|
|
*/ |
|
131
|
|
|
public function setDecodedJsonData($decodedJsonData) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->decodedJsonData = $decodedJsonData; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Returns previous page number (or null). |
|
138
|
|
|
* @return integer|null |
|
139
|
|
|
*/ |
|
140
|
|
|
public function getPrevPage() |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->prevPage; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Set previous page number. |
|
147
|
|
|
* @param integer|null $prevPage |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setPrevPage($prevPage) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->prevPage = $prevPage; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Returns next page number (or null). |
|
156
|
|
|
* @return integer|null |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getNextPage() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->nextPage; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Set next page number. |
|
165
|
|
|
* @param integer|null $nextPage |
|
166
|
|
|
*/ |
|
167
|
|
|
public function setNextPage($nextPage) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->nextPage = $nextPage; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Return last page number |
|
174
|
|
|
* @return integer|null |
|
175
|
|
|
*/ |
|
176
|
|
|
public function getLastPage() |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->lastPage; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Set last page number. |
|
183
|
|
|
* @param integer|null $lastPage |
|
184
|
|
|
*/ |
|
185
|
|
|
public function setLastPage($lastPage) |
|
186
|
|
|
{ |
|
187
|
|
|
$this->lastPage = $lastPage; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
public function getRateLimit() |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->rateLimit; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
public function setRateLimit($rateLimit) |
|
196
|
|
|
{ |
|
197
|
|
|
$this->rateLimit = $rateLimit; |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
public function getRateLimitRemaining() |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->rateLimitRemaining; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
public function setRateLimitRemaining($rateLimitRemaining) |
|
206
|
|
|
{ |
|
207
|
|
|
$this->rateLimitRemaining = $rateLimitRemaining; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
public function getRateLimitReset() |
|
211
|
|
|
{ |
|
212
|
|
|
return $this->rateLimitReset; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
public function setRateLimitReset($rateLimitReset) |
|
216
|
|
|
{ |
|
217
|
|
|
$this->rateLimitReset = $rateLimitReset; |
|
218
|
|
|
} |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
|
|
222
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.