Passed
Pull Request — master (#35)
by
unknown
03:59 queued 02:21
created

Response::hasHeader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
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
16
    public function getHeader(string $name, $default = null): mixed
17
    {
18
        return $this->headers[$name] ?? $default;
19
    }
20
21
    public function getHeaders(): array
22
    {
23
        return $this->headers;
24
    }
25
26
    public function hasHeader(string $name): bool
27
    {
28
        return isset($this->headers[$name]);
29
    }
30
31
    public function getBody(): array|string
32
    {
33
        return $this->body;
34
    }
35
36
    public function getRequestedUrl(): string
37
    {
38
        return $this->requestedUrl;
39
    }
40
41
    public function hasBody(): bool
42
    {
43
        return !empty($this->body);
44
    }
45
46
    public function getHttpResponseCode(): ?int
47
    {
48
        return $this->statusCode;
49
    }
50
}
51