Laravel Cloudflare

PHP MIT

Complete Laravel Cloudflare API SDK for managing DNS records, zones, cache, SSL, firewall rules, workers, analytics, and Cloudflare services with a fluent Laravel-first developer experience.

Stars
2
Forks
0
Downloads
N/A
Open Issues
0
Files main

Repository Files

Loading file structure...
src/Exceptions/RateLimitException.php
<?php

namespace Vendor\Cloudflare\Exceptions;

class RateLimitException extends ApiException
{
    protected ?int $limit = null;

    protected ?int $remaining = null;

    protected ?int $reset = null;

    public function __construct(
        string $message,
        int $code,
        string $errorCode = '',
        array $details = [],
        ?int $limit = null,
        ?int $remaining = null,
        ?int $reset = null,
        ?\Throwable $previous = null
    ) {
        parent::__construct($message, $code, $errorCode, $details, $previous);
        $this->limit = $limit;
        $this->remaining = $remaining;
        $this->reset = $reset;
    }

    public function getLimit(): ?int
    {
        return $this->limit;
    }

    public function getRemaining(): ?int
    {
        return $this->remaining;
    }

    public function getResetTimestamp(): ?int
    {
        return $this->reset;
    }

    public function getSecondsUntilReset(): int
    {
        if ($this->reset === null) {
            return 60;
        }

        return max(0, $this->reset - time());
    }
}