RedirectBucket::getLocation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace roxblnfk\SmartStream\Data;
6
7
use Yiisoft\Http\Header;
8
use Yiisoft\Http\Status;
9
10
class RedirectBucket extends DataBucket
11
{
12
    protected ?string $location = null;
13
14
    protected const IS_CONVERTABLE = false;
15
16 11
    public function __construct(string $location, int $code = Status::FOUND)
17
    {
18 11
        parent::__construct('');
19 11
        $this->setLocation($location);
20 11
        $this->setStatusCode($code);
21 11
    }
22 3
    public function getLocation(): ?string
23
    {
24 3
        return $this->location;
25
    }
26 2
    public function withLocation(?string $location): self
27
    {
28 2
        $new = clone $this;
29 2
        $new->setLocation($location);
30 2
        return $new;
31
    }
32
33 11
    protected function setLocation(?string $location): void
34
    {
35 11
        $this->location = $location;
36 11
        $this->setHeader(Header::LOCATION, $this->location);
37 11
    }
38
}
39