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

RateLimitReached   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getRetryAfter() 0 2 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
}