Response::__toString()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Router\Entities;
6
7
use Override;
8
use Stringable;
9
10
class Response implements Stringable
11
{
12
    /**
13
     * @param list<string> $headers
14 8
     */
15
    public function __construct(
16
        private string $content,
17
        private array $headers = [],
18 8
    ) {
19
    }
20 8
21
    #[Override]
22 8
    public function __toString(): string
23 5
    {
24
        foreach ($this->headers as $header) {
25
            header($header);
26 8
        }
27
28
        return $this->content;
29
    }
30
}
31