1<?php 2 3namespace Sabre\HTTP; 4 5/** 6 * Request Decorator 7 * 8 * This helper class allows you to easily create decorators for the Request 9 * object. 10 * 11 * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/). 12 * @author Evert Pot (http://evertpot.com/) 13 * @license http://sabre.io/license/ Modified BSD License 14 */ 15class RequestDecorator implements RequestInterface { 16 17 use MessageDecoratorTrait; 18 19 /** 20 * Constructor. 21 * 22 * @param RequestInterface $inner 23 */ 24 function __construct(RequestInterface $inner) { 25 26 $this->inner = $inner; 27 28 } 29 30 /** 31 * Returns the current HTTP method 32 * 33 * @return string 34 */ 35 function getMethod() { 36 37 return $this->inner->getMethod(); 38 39 } 40 41 /** 42 * Sets the HTTP method 43 * 44 * @param string $method 45 * @return void 46 */ 47 function setMethod($method) { 48 49 $this->inner->setMethod($method); 50 51 } 52 53 /** 54 * Returns the request url. 55 * 56 * @return string 57 */ 58 function getUrl() { 59 60 return $this->inner->getUrl(); 61 62 } 63 64 /** 65 * Sets the request url. 66 * 67 * @param string $url 68 * @return void 69 */ 70 function setUrl($url) { 71 72 $this->inner->setUrl($url); 73 74 } 75 76 /** 77 * Returns the absolute url. 78 * 79 * @return string 80 */ 81 function getAbsoluteUrl() { 82 83 return $this->inner->getAbsoluteUrl(); 84 85 } 86 87 /** 88 * Sets the absolute url. 89 * 90 * @param string $url 91 * @return void 92 */ 93 function setAbsoluteUrl($url) { 94 95 $this->inner->setAbsoluteUrl($url); 96 97 } 98 99 /** 100 * Returns the current base url. 101 * 102 * @return string 103 */ 104 function getBaseUrl() { 105 106 return $this->inner->getBaseUrl(); 107 108 } 109 110 /** 111 * Sets a base url. 112 * 113 * This url is used for relative path calculations. 114 * 115 * The base url should default to / 116 * 117 * @param string $url 118 * @return void 119 */ 120 function setBaseUrl($url) { 121 122 $this->inner->setBaseUrl($url); 123 124 } 125 126 /** 127 * Returns the relative path. 128 * 129 * This is being calculated using the base url. This path will not start 130 * with a slash, so it will always return something like 131 * 'example/path.html'. 132 * 133 * If the full path is equal to the base url, this method will return an 134 * empty string. 135 * 136 * This method will also urldecode the path, and if the url was incoded as 137 * ISO-8859-1, it will convert it to UTF-8. 138 * 139 * If the path is outside of the base url, a LogicException will be thrown. 140 * 141 * @return string 142 */ 143 function getPath() { 144 145 return $this->inner->getPath(); 146 147 } 148 149 /** 150 * Returns the list of query parameters. 151 * 152 * This is equivalent to PHP's $_GET superglobal. 153 * 154 * @return array 155 */ 156 function getQueryParameters() { 157 158 return $this->inner->getQueryParameters(); 159 160 } 161 162 /** 163 * Returns the POST data. 164 * 165 * This is equivalent to PHP's $_POST superglobal. 166 * 167 * @return array 168 */ 169 function getPostData() { 170 171 return $this->inner->getPostData(); 172 173 } 174 175 /** 176 * Sets the post data. 177 * 178 * This is equivalent to PHP's $_POST superglobal. 179 * 180 * This would not have been needed, if POST data was accessible as 181 * php://input, but unfortunately we need to special case it. 182 * 183 * @param array $postData 184 * @return void 185 */ 186 function setPostData(array $postData) { 187 188 $this->inner->setPostData($postData); 189 190 } 191 192 193 /** 194 * Returns an item from the _SERVER array. 195 * 196 * If the value does not exist in the array, null is returned. 197 * 198 * @param string $valueName 199 * @return string|null 200 */ 201 function getRawServerValue($valueName) { 202 203 return $this->inner->getRawServerValue($valueName); 204 205 } 206 207 /** 208 * Sets the _SERVER array. 209 * 210 * @param array $data 211 * @return void 212 */ 213 function setRawServerData(array $data) { 214 215 $this->inner->setRawServerData($data); 216 217 } 218 219 /** 220 * Serializes the request object as a string. 221 * 222 * This is useful for debugging purposes. 223 * 224 * @return string 225 */ 226 function __toString() { 227 228 return $this->inner->__toString(); 229 230 } 231} 232