Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Rate_Limit_Exception | |
0.00% |
0 / 2 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_reset_time | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @see https://github.com/ietf-wg-httpapi/ratelimit-headers |
| 4 | * @see https://datatracker.ietf.org/doc/draft-ietf-httpapi-ratelimit-headers/ |
| 5 | * |
| 6 | * 'X-RateLimit-Limit' |
| 7 | * 'X-RateLimit-Remaining' |
| 8 | * |
| 9 | * TODO: not this exactly, but when an API that has been used for a while starts to fail (this happened with SoChain |
| 10 | * removing their unauthenticated free tier), we need to rate limit outgoing requests to it. |
| 11 | * |
| 12 | * @package brianhenryie/bh-wp-bitcoin-gateway |
| 13 | */ |
| 14 | |
| 15 | namespace BrianHenryIE\WP_Bitcoin_Gateway\API\Model\Exceptions; |
| 16 | |
| 17 | use DateTimeInterface; |
| 18 | use Throwable; |
| 19 | |
| 20 | /** |
| 21 | * Internal class to hopefully communicate when the external API calls can be attempted again. |
| 22 | */ |
| 23 | class Rate_Limit_Exception extends BH_WP_Bitcoin_Gateway_Exception { |
| 24 | |
| 25 | /** |
| 26 | * Constructor. |
| 27 | * |
| 28 | * @param ?DateTimeInterface $reset_time When the rate limit will reset, if known. |
| 29 | * @param string $message Exception message. |
| 30 | * @param int $code Exception code. |
| 31 | * @param ?Throwable $previous Previous exception. |
| 32 | */ |
| 33 | public function __construct( |
| 34 | protected ?DateTimeInterface $reset_time = null, |
| 35 | string $message = '', |
| 36 | int $code = 0, |
| 37 | ?Throwable $previous = null |
| 38 | ) { |
| 39 | parent::__construct( $message, $code, $previous ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get the time when the API can be next used, `null` if unknown. |
| 44 | */ |
| 45 | public function get_reset_time(): ?DateTimeInterface { |
| 46 | return $this->reset_time; |
| 47 | } |
| 48 | } |