1 | <?php |
||
26 | class Curl |
||
27 | { |
||
28 | /** |
||
29 | * The data to send with each request. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $data; |
||
34 | |||
35 | /** |
||
36 | * The request dispatcher to use. |
||
37 | * |
||
38 | * @var DispatcherInterface |
||
39 | */ |
||
40 | protected $dispatcher; |
||
41 | |||
42 | /** |
||
43 | * Which HTTP verb to use. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $verb; |
||
48 | |||
49 | /** |
||
50 | * The requests that should be sent. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $requests; |
||
55 | |||
56 | /** |
||
57 | * Make one or multiple DELETE requests. |
||
58 | * |
||
59 | * @param mixed $urls |
||
60 | * @param mixed $data |
||
61 | * @param callable $callback |
||
62 | * @return array |
||
63 | */ |
||
64 | public static function delete($urls, $data = null, callable $callback = null) |
||
68 | |||
69 | /** |
||
70 | * Make one or multiple GET requests. |
||
71 | * |
||
72 | * @param mixed $urls |
||
73 | * @param mixed $data |
||
74 | * @param callable $callback |
||
75 | * @return array |
||
76 | */ |
||
77 | public static function get($urls, $data = null, callable $callback = null) |
||
81 | |||
82 | /** |
||
83 | * Make one or multiple POST requests. |
||
84 | * |
||
85 | * @param mixed $urls |
||
86 | * @param mixed $data |
||
87 | * @param callable $callback |
||
88 | * @return array |
||
89 | */ |
||
90 | public static function post($urls, $data = null, callable $callback = null) |
||
94 | |||
95 | /** |
||
96 | * Make one or multiple PUT requests. |
||
97 | * |
||
98 | * @param mixed $urls |
||
99 | * @param mixed $data |
||
100 | * @param callable $callback |
||
101 | * @return array |
||
102 | */ |
||
103 | public static function put($urls, $data = null, callable $callback = null) |
||
107 | |||
108 | /** |
||
109 | * Make one or multiple requests. |
||
110 | * |
||
111 | * @param string $verb |
||
112 | * @param mixed $urls |
||
113 | * @param mixed $data |
||
114 | * @param callable $callback |
||
115 | * @return array |
||
116 | */ |
||
117 | protected static function make($verb, $urls, $data, callable $callback = null) |
||
148 | |||
149 | /** |
||
150 | * Constructs a `Curl` instance. |
||
151 | * |
||
152 | * @param string $verb |
||
153 | * @param DispatcherInterface $dispatcher |
||
154 | * @param array $requests |
||
155 | * @param array $data |
||
156 | * @param callable $callback |
||
157 | */ |
||
158 | protected function __construct( |
||
175 | |||
176 | /** |
||
177 | * Prepares and sends HTTP requests. |
||
178 | * |
||
179 | * @param callable $callback |
||
180 | */ |
||
181 | protected function makeRequest(callable $callback = null) |
||
216 | |||
217 | /** |
||
218 | * Sets a request's HTTP verb to DELETE. |
||
219 | * |
||
220 | * @param RequestInterface $request |
||
221 | */ |
||
222 | protected function prepareDeleteRequest(RequestInterface $request) |
||
226 | |||
227 | /** |
||
228 | * Sets a request's HTTP verb to GET. |
||
229 | * |
||
230 | * @param RequestInterface $request |
||
231 | */ |
||
232 | protected function prepareGetRequest(RequestInterface $request) |
||
236 | |||
237 | /** |
||
238 | * Sets a request's HTTP verb to POST. |
||
239 | * |
||
240 | * @param RequestInterface $request |
||
241 | */ |
||
242 | protected function preparePostRequest(RequestInterface $request, $data) |
||
252 | |||
253 | /** |
||
254 | * Sets a request's HTTP verb to PUT. |
||
255 | * |
||
256 | * @param RequestInterface $request |
||
257 | */ |
||
258 | protected function preparePutRequest(RequestInterface $request, $data) |
||
265 | } |
||
266 |