PayloadTooLarge::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 2
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 '413 Payload Too Large' HTTP status response.
10
 *
11
 * @see https://tools.ietf.org/html/rfc7231#section-6.5.11
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 PayloadTooLarge 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 'Payload Too Large' 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(413, 'Payload Too Large', $headers);
32 6
    }
33
}
34