RedirectResponse::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 2
nop 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Furious\Psr7\Response;
6
7
use Furious\Psr7\Exception\InvalidArgumentException;
8
use Furious\Psr7\Response;
9
use Psr\Http\Message\UriInterface;
10
11
class RedirectResponse extends Response
12
{
13
    public function __construct($uri, int $statusCode = 302, array $headers = [], $body = null, string $version = '1.1', string $reason = null)
14
    {
15
        if (!is_string($uri) and !$uri instanceof UriInterface) {
16
            throw new InvalidArgumentException('Uri must be a string or an instance of UriInterface');
17
        }
18
19
        parent::__construct($statusCode, $headers + [
20
            'Location' => (string) $uri
21
        ], '', $version, $reason);
22
    }
23
}