UpgradeRequired::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
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 '426 Upgrade Required' HTTP status response.
9
 *
10
 * @see https://tools.ietf.org/html/rfc6585#section-4
11
 * @author Nathan Bishop <[email protected]> (https://nathanbishop.name)
12
 * @copyright 2016 Nathan Bishop
13
 * @license The MIT license.
14
 */
15
class UpgradeRequired extends ClientError
16
{
17
    /**
18
     * Construct a new 'Upgrade Required' exception.
19
     *
20
     * @param string[] $protocols A list of supported protocols the client should select from before retrying the request.
21
     * @param string[][] $headers Additional headers associated with the exception.
22
     */
23 5
    public function __construct(array $protocols, array $headers = [])
24
    {
25 5
        $headers = array_merge($headers, [
26 5
            'upgrade' => $protocols,
27
            'connection' => ['upgrade']
28
        ]);
29
30 5
        parent::__construct(426, 'Upgrade Required', $headers);
31 5
    }
32
}
33