RedirectBucket   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setLocation() 0 4 1
A __construct() 0 5 1
A getLocation() 0 3 1
A withLocation() 0 5 1
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