UnavailableForLegalReasons::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Meek\Http\ClientError;
4
5
use Meek\Http\ClientError;
6
7
/**
8
 * Exception modeling the '451 Unavailable For Legal Reasons' HTTP status response.
9
 *
10
 * @link https://tools.ietf.org/html/rfc7725#section-3
11
 * @author Nathan Bishop <[email protected]> (https://nathanbishop.name)
12
 * @copyright 2016 Nathan Bishop
13
 * @license The MIT license.
14
 */
15
class UnavailableForLegalReasons extends ClientError
16
{
17
    /**
18
     * Construct a new 'Unavailable For Legal Reasons' exception.
19
     *
20
     * @param string $link A URI reference identifying the resource itself.
21
     * @param string[][] $headers Headers to be sent along with the prepared response.
22
     */
23 4
    public function __construct(string $link, array $headers = [])
24
    {
25 4
        $link = '<' . $link . '>; rel="blocked-by"';
26 4
        $headers = array_merge($headers, ['link' => [$link]]);
27
28 4
        parent::__construct(451, 'Unavailable For Legal Reasons', $headers);
29 4
    }
30
}
31