Skip to content

Commit d28f25d

Browse files
committed
Add getTrailer() method
1 parent 133aacb commit d28f25d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Server/Response.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function withContent(string $content): self
3838
}
3939

4040
/**
41-
* Return an instance with specified cookies.
41+
* Returns an instance with specified cookies.
4242
*/
4343
public function withCookie(Cookie $cookie): self
4444
{
@@ -48,20 +48,34 @@ public function withCookie(Cookie $cookie): self
4848
}
4949

5050
/**
51-
* Return all cookies.
51+
* Retrieves all cookies.
5252
*/
5353
public function getCookies(): array
5454
{
5555
return $this->cookies;
5656
}
5757

58+
/**
59+
* Returns an instance with specified trailer.
60+
*/
5861
public function withTrailer(string $key, $value): self
5962
{
6063
$new = clone $this;
6164
$new->trailers[$key] = $value;
6265
return $new;
6366
}
6467

68+
/**
69+
* Retrieves a specified trailer value, returns null if the value does not exists.
70+
*/
71+
public function getTrailer(string $key)
72+
{
73+
return $this->trailers[$key] ?? null;
74+
}
75+
76+
/**
77+
* Retrieves all trailers values.
78+
*/
6579
public function getTrailers(): array
6680
{
6781
return $this->trailers;

0 commit comments

Comments
 (0)