Total Complexity | 10 |
Total Lines | 52 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | class Request implements RequestInterface |
||
21 | { |
||
22 | use THeaders; |
||
23 | use TBody; |
||
24 | use TProtocol; |
||
25 | |||
26 | protected string $target = ''; |
||
27 | protected string $method = 'GET'; |
||
28 | protected ?UriInterface $uri = null; |
||
29 | |||
30 | 4 | public function getRequestTarget(): string |
|
33 | } |
||
34 | |||
35 | 1 | public function withRequestTarget(string $requestTarget): RequestInterface |
|
39 | } |
||
40 | |||
41 | 4 | public function getMethod(): string |
|
42 | { |
||
43 | 4 | return $this->method; |
|
44 | } |
||
45 | |||
46 | 1 | public function withMethod(string $method): RequestInterface |
|
50 | } |
||
51 | |||
52 | 5 | public function getUri(): UriInterface |
|
53 | { |
||
54 | 5 | if (is_null($this->uri)) { |
|
55 | 1 | throw new RuntimeException('You must set URI first!'); |
|
56 | } |
||
57 | 4 | return $this->uri; |
|
58 | } |
||
59 | |||
60 | 4 | public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface |
|
61 | { |
||
62 | 4 | $this->uri = $uri; |
|
63 | 4 | $this->withHeader('Host', $this->createHostHeader($uri)); |
|
64 | 4 | return $this; |
|
65 | } |
||
66 | |||
67 | 4 | protected function createHostHeader(UriInterface $uri): string |
|
72 | } |
||
73 | } |
||
74 |