| Total Complexity | 14 |
| Total Lines | 111 |
| Duplicated Lines | 0 % |
| Coverage | 20% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | trait RequestTrait |
||
| 7 | { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $method; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $requestTarget; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var UriInterface |
||
| 21 | */ |
||
| 22 | private $uri; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @return string |
||
| 26 | */ |
||
| 27 | 4 | public function getMethod() |
|
| 28 | { |
||
| 29 | 4 | return $this->method; |
|
| 30 | } |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $method |
||
| 34 | * @return \DevOp\Core\Http\Request|$this |
||
| 35 | */ |
||
| 36 | 2 | public function withMethod($method) |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public function getRequestTarget() |
||
| 52 | { |
||
| 53 | |||
| 54 | if ($this->requestTarget) { |
||
| 55 | return $this->requestTarget; |
||
| 56 | } |
||
| 57 | |||
| 58 | $target = $this->uri->getPath(); |
||
| 59 | |||
| 60 | if ($target === '') { |
||
| 61 | $target .= '/'; |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($this->uri->getQuery()) { |
||
| 65 | $target .= '?' . $this->uri->getQuery(); |
||
| 66 | } |
||
| 67 | |||
| 68 | return $target; |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param string $requestTarget |
||
| 73 | * @return \DevOp\Core\Http\Request|$this |
||
| 74 | */ |
||
| 75 | public function withRequestTarget($requestTarget) |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @return UriInterface |
||
| 89 | */ |
||
| 90 | public function getUri() |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @param UriInterface $uri |
||
| 97 | * @param boolean $preserveHost |
||
| 98 | * @return \DevOp\Core\Http\Request|$this |
||
| 99 | */ |
||
| 100 | public function withUri(UriInterface $uri, $preserveHost = false) |
||
| 119 |