-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathStreamFeedException.php
More file actions
43 lines (34 loc) · 957 Bytes
/
StreamFeedException.php
File metadata and controls
43 lines (34 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace GetStream\Stream;
use GuzzleHttp\Exception\ClientException;
class StreamFeedException extends \Exception
{
private function getRateLimitValue($headerName)
{
/* Sample headers
x-ratelimit-limit: 2000
x-ratelimit-remaining: 1998
x-ratelimit-reset: 1543604520
*/
$e = $this->getPrevious();
if ($e && $e instanceof ClientException) {
$headerValues = $e->getResponse()->getHeader("x-ratelimit-" . $headerName);
if ($headerValues) {
return $headerValues[0];
}
}
return null;
}
public function getRateLimitLimit()
{
return $this->getRateLimitValue("limit");
}
public function getRateLimitRemaining()
{
return $this->getRateLimitValue("remaining");
}
public function getRateLimitReset()
{
return $this->getRateLimitValue("reset");
}
}