TooManyRequests   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 6
cts 6
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\ClientError;
4
5
use Meek\Http\ClientError;
6
use DateTimeInterface;
7
8
/**
9
 * Exception modeling the '429 Too Many Requests' HTTP status response.
10
 *
11
 * @see https://tools.ietf.org/html/rfc6585#section-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 TooManyRequests extends ClientError
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 'Too Many Requests' exception.
20
     *
21
     * @param DateTimeInterface|null $retryAfter How long before the client should retry 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 3
            $retryAfter = [$retryAfter->format('D, d M Y H:i:s \G\M\T')];
28 3
            $headers = array_merge($headers, ['retry-after' => $retryAfter]);
29
        }
30
31 6
        parent::__construct(429, 'Too Many Requests', $headers);
32 6
    }
33
}
34