ServiceUnavailable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 18
loc 18
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php declare(strict_types=1);
2
3
namespace Meek\Http\ServerError;
4
5
use Meek\Http\ServerError;
6
use DateTimeInterface;
7
8
/**
9
 * Exception modeling the '503 Service Unavailable' HTTP status response.
10
 *
11
 * @see https://tools.ietf.org/html/rfc7231#section-6.6.4
12
 * @author Nathan Bishop <[email protected]> (https://nathanbishop.name)
13
 * @copyright 2016 Nathan Bishop
14
 * @license The MIT license.
15
 */
16 View Code Duplication
class ServiceUnavailable extends ServerError
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * Construct a new 'Service Unavailable' exception.
20
     *
21
     * @param DateTimeInterface|null $retryAfter If provided, how long the client should wait before retrying the request.
22
     * @param string[][] $headers Additional headers associated with the exception.
23
     */
24 6
    public function __construct(DateTimeInterface $retryAfter = null, array $headers = [])
25
    {
26 6
        if ($retryAfter) {
27
            // RFC7231, Section 7.1.1: http://tools.ietf.org/html/rfc7231
28 3
            $headers = array_merge($headers, ['retry-after' => [$retryAfter->format('D, d M Y H:i:s \G\M\T')]]);
29
        }
30
31 6
        parent::__construct(503, 'Service Unavailable', $headers);
32 6
    }
33
}
34