Passed
Push — master ( 1a72b2...62395a )
by Fabian
02:20
created

RateLimitReached::getRetryAfter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace LE_ACME2\Exception;
4
5
class RateLimitReached extends AbstractException {
6
7
    /** @var string|null */
8
    private $retryAfter;
9
10 2
    public function __construct(string $request, string $detail, string $retryAfter = null) {
11 2
        parent::__construct(
12 2
            "Invalid response received for request (" . $request . "): " .
13
            "rate limit reached - " . $detail
14
        );
15
16 2
        $this->retryAfter = $retryAfter;
17
    }
18
19
    /**
20
     * Returns the value of the given Retry-After header
21
     *
22
     * Retry-After: <http-date>
23
     * Retry-After: <delay-seconds>
24
     * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
25
     *
26
     * @return string|null <http-date> or <delay-seconds> or null (when not given)
27
     */
28 1
    public function getRetryAfter() : ?string {
29 1
        return $this->retryAfter;
30
    }
31
}