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