Response::getHeaders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Rogierw\RwAcme\Http;
4
5
class Response
6
{
7
    public function __construct(
8
        private readonly array $headers,
9
        private readonly string $requestedUrl,
10
        private readonly ?int $statusCode,
11
        private readonly array|string $body,
12
    ) {
13
    }
14
15
    public function getHeader(string $name, $default = null): mixed
16
    {
17
        return $this->headers[$name] ?? $default;
18
    }
19
20
    public function getHeaders(): array
21
    {
22
        return $this->headers;
23
    }
24
25
    public function hasHeader(string $name): bool
26
    {
27
        return isset($this->headers[$name]);
28
    }
29
30
    public function getBody(): array|string
31
    {
32
        return $this->body;
33
    }
34
35
    public function getRequestedUrl(): string
36
    {
37
        return $this->requestedUrl;
38
    }
39
40
    public function hasBody(): bool
41
    {
42
        return !empty($this->body);
43
    }
44
45
    public function getHttpResponseCode(): ?int
46
    {
47
        return $this->statusCode;
48
    }
49
}
50