aboutsummaryrefslogtreecommitdiff
path: root/tests/Fixtures/TestRequest.php
blob: c449610166fc9026f19b1c3397db5fdde6d4bc79 (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
<?php

declare(strict_types=1);

namespace BrettParson\MiniRoute\Tests\Fixtures;

use BrettParson\MiniRoute\Http\RequestInterface;

final class TestRequest implements RequestInterface
{
    /**
     * @param array<string, string> $params
     */
    public function __construct(
        private readonly string $method,
        private readonly string $path,
        private readonly array $params = [],
    ) {
    }

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

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

    public function param(string $name, string $default = ''): string
    {
        return $this->params[$name] ?? $default;
    }

    public function withParams(array $params): RequestInterface
    {
        return new self($this->method, $this->path, $params);
    }
}