1 | <?php |
||
22 | class MultiRequest{ |
||
23 | |||
24 | /** |
||
25 | * the curl_multi master handle |
||
26 | * |
||
27 | * @var resource |
||
28 | */ |
||
29 | protected $curl_multi; |
||
30 | |||
31 | /** |
||
32 | * cURL options for each handle |
||
33 | * |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $curl_options = []; |
||
37 | |||
38 | /** |
||
39 | * An array of the request URLs |
||
40 | * |
||
41 | * @var array<\chillerlan\TinyCurl\URL> |
||
42 | */ |
||
43 | protected $stack = []; |
||
44 | |||
45 | /** |
||
46 | * The returned value from MultiResponseHandlerInterface::handleResponse() for each request |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $responses = []; |
||
51 | |||
52 | /** |
||
53 | * @var \chillerlan\TinyCurl\MultiRequestOptions |
||
54 | */ |
||
55 | protected $options; |
||
56 | |||
57 | /** |
||
58 | * @var \chillerlan\TinyCurl\Response\MultiResponseHandlerInterface |
||
59 | */ |
||
60 | protected $multiResponseHandler; |
||
61 | |||
62 | /** |
||
63 | * MultiRequest constructor. |
||
64 | * |
||
65 | * @param \chillerlan\TinyCurl\MultiRequestOptions|null $options |
||
66 | */ |
||
67 | public function __construct(MultiRequestOptions $options = null){ |
||
76 | |||
77 | /** |
||
78 | * closes the curl_multi instance |
||
79 | * |
||
80 | * @codeCoverageIgnore |
||
81 | */ |
||
82 | public function __destruct(){ |
||
87 | |||
88 | /** |
||
89 | * @param \chillerlan\TinyCurl\Response\MultiResponseHandlerInterface|null $handler |
||
90 | * |
||
91 | * @return $this |
||
92 | * @throws \chillerlan\TinyCurl\RequestException |
||
93 | */ |
||
94 | public function setHandler(MultiResponseHandlerInterface $handler = null){ |
||
114 | |||
115 | /** |
||
116 | * @param array $urls array of \chillerlan\TinyCurl\URL objects |
||
117 | * |
||
118 | * @return $this |
||
119 | * @throws \chillerlan\TinyCurl\RequestException |
||
120 | */ |
||
121 | public function fetch(array $urls){ |
||
144 | |||
145 | /** |
||
146 | * @param mixed $response |
||
147 | * |
||
148 | * @see \chillerlan\TinyCurl\Response\MultiResponseHandlerInterface |
||
149 | * @return $this |
||
150 | */ |
||
151 | public function addResponse($response){ |
||
156 | |||
157 | /** |
||
158 | * @return array |
||
159 | */ |
||
160 | public function getResponseData(){ |
||
163 | |||
164 | /** |
||
165 | * @return void |
||
166 | * @throws \chillerlan\TinyCurl\RequestException |
||
167 | */ |
||
168 | protected function setOptions(){ |
||
183 | |||
184 | /** |
||
185 | * creates a new cURL handle |
||
186 | */ |
||
187 | protected function createHandle(){ |
||
205 | |||
206 | /** |
||
207 | * processes the requests |
||
208 | */ |
||
209 | protected function processStack(){ |
||
237 | |||
238 | } |
||
239 |