1 <?php
2
3 namespace Http\Message\Decorator;
4
5 use Psr\Http\Message\RequestInterface;
6 use Psr\Http\Message\UriInterface;
7
8 9 10
11 trait RequestDecorator
12 {
13 use MessageDecorator {
14 getMessage as getRequest;
15 }
16
17 18 19 20 21 22 23
24 public function withRequest(RequestInterface $request)
25 {
26 $new = clone $this;
27 $new->message = $request;
28
29 return $new;
30 }
31
32 33 34
35 public function getRequestTarget()
36 {
37 return $this->message->getRequestTarget();
38 }
39
40 41 42
43 public function withRequestTarget($requestTarget)
44 {
45 $new = clone $this;
46 $new->message = $this->message->withRequestTarget($requestTarget);
47
48 return $new;
49 }
50
51 52 53
54 public function getMethod()
55 {
56 return $this->message->getMethod();
57 }
58
59 60 61
62 public function withMethod($method)
63 {
64 $new = clone $this;
65 $new->message = $this->message->withMethod($method);
66
67 return $new;
68 }
69
70 71 72
73 public function getUri()
74 {
75 return $this->message->getUri();
76 }
77
78 79 80
81 public function withUri(UriInterface $uri, $preserveHost = false)
82 {
83 $new = clone $this;
84 $new->message = $this->message->withUri($uri, $preserveHost);
85
86 return $new;
87 }
88 }
89