| Total Complexity | 14 |
| Total Lines | 117 |
| Duplicated Lines | 0 % |
| Coverage | 20% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | trait RequestTrait |
||
| 7 | { |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | protected $method; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $requestTarget; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var UriInterface |
||
| 21 | */ |
||
| 22 | protected $uri; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string $name |
||
| 26 | * @return boolean |
||
| 27 | */ |
||
| 28 | abstract public function hasHeader($name); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | 4 | public function getMethod() |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string $method |
||
| 40 | * @return self |
||
| 41 | */ |
||
| 42 | 2 | public function withMethod($method) |
|
| 43 | { |
||
| 44 | 2 | if ($method === $this->method) { |
|
| 45 | return $this; |
||
| 46 | } |
||
| 47 | |||
| 48 | 2 | $clone = clone $this; |
|
| 49 | 2 | $clone->method = $method; |
|
| 50 | |||
| 51 | 2 | return $clone; |
|
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return string |
||
| 56 | */ |
||
| 57 | public function getRequestTarget() |
||
| 58 | { |
||
| 59 | |||
| 60 | if ($this->requestTarget) { |
||
| 61 | return $this->requestTarget; |
||
| 62 | } |
||
| 63 | |||
| 64 | $target = $this->uri->getPath(); |
||
| 65 | |||
| 66 | if ($target === '') { |
||
| 67 | $target .= '/'; |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($this->uri->getQuery()) { |
||
| 71 | $target .= '?' . $this->uri->getQuery(); |
||
| 72 | } |
||
| 73 | |||
| 74 | return $target; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @param string $requestTarget |
||
| 79 | * @return self |
||
| 80 | */ |
||
| 81 | public function withRequestTarget($requestTarget) |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @return UriInterface |
||
| 95 | */ |
||
| 96 | public function getUri() |
||
| 99 | } |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @param UriInterface $uri |
||
| 103 | * @param boolean $preserveHost |
||
| 104 | * @return self |
||
| 105 | */ |
||
| 106 | public function withUri(UriInterface $uri, $preserveHost = false) |
||
| 125 |