| 1 | <?php |
||
| 9 | final class Request |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The url for this request |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $_url; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The HTTP method for this request |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $_method; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * The body for this request |
||
| 27 | * |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | private $_body; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * The HTTP headers for this request |
||
| 34 | * |
||
| 35 | * @var array |
||
| 36 | */ |
||
| 37 | private $_headers; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Create a new request instance |
||
| 41 | * |
||
| 42 | * @param string $url |
||
| 43 | * @param string $method |
||
| 44 | * @param string|null $body |
||
| 45 | * @param array $headers |
||
| 46 | * |
||
| 47 | * @throws \InvalidArgumentException Thrown if $url is not a non-empty string |
||
| 48 | * @throws \InvalidArgumentException Thrown if $method is not a non-empty string |
||
| 49 | * @throws \InvalidArgumentException Thrown if $body is not null or not a non-empty string |
||
| 50 | */ |
||
| 51 | public function __construct($url, $method, $body = null, array $headers = []) |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Get the url of this request |
||
| 64 | * |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function getUrl() |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Get the method of this request |
||
| 74 | * |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | public function getMethod() |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Get the body of this request |
||
| 84 | * |
||
| 85 | * @return string |
||
| 86 | */ |
||
| 87 | public function getBody() |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Get the headers of this request |
||
| 94 | * |
||
| 95 | * @return array |
||
| 96 | */ |
||
| 97 | public function getHeaders() |
||
| 101 | } |
||
| 102 |