aboutsummaryrefslogtreecommitdiff
path: root/tests/Fixtures/TestResponse.php
blob: 25a0307d0bdda3ad4afcf7b4582820753ee719fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

declare(strict_types=1);

namespace BrettParson\MiniRoute\Tests\Fixtures;

use BrettParson\MiniRoute\Http\ResponseInterface;

final class TestResponse implements ResponseInterface
{
    /**
     * @param array<string, string> $headers
     */
    public function __construct(
        private readonly int $status,
        private readonly string $body,
        private readonly array $headers = [],
    ) {
    }

    public function status(): int
    {
        return $this->status;
    }

    public function body(): string
    {
        return $this->body;
    }

    public function withHeader(string $name, string $value): ResponseInterface
    {
        return new self($this->status, $this->body, array_merge($this->headers, [$name => $value]));
    }

    /**
     * @return array<string, string>
     */
    public function headers(): array
    {
        return $this->headers;
    }
}