ServiceUnavailable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getRetryAfter() 0 2 1
1
<?php
2
3
namespace LE_ACME2\Exception;
4
5
class ServiceUnavailable extends AbstractException {
6
7
    private ?string $retryAfter;
8
9
    public function __construct(string $request, string $detail, string $retryAfter = null) {
10 2
11
        $message = "Invalid response received for request (" . $request . "): service unavailable - " . $detail;
12 2
13
        if($retryAfter !== null) {
14 2
            $message .= ' - may retry after: ' . $retryAfter;
15 1
        }
16
17
        parent::__construct($message);
18 2
19
        $this->retryAfter = $retryAfter;
20 2
    }
21
22
    /**
23
     * Returns the value of the given Retry-After header
24
     *
25
     * Retry-After: <http-date>
26
     * Retry-After: <delay-seconds>
27
     * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
28
     *
29
     * @return ?string  "http-date" or "delay-seconds" or null (when not given)
30
     */
31
    public function getRetryAfter() : ?string {
32 1
        return $this->retryAfter;
33
    }
34
}