| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function execute(array $urls) : array |
||
| 18 | { |
||
| 19 | $handles = []; |
||
| 20 | $result = []; |
||
| 21 | $multiHandle = \curl_multi_init(); |
||
| 22 | |||
| 23 | foreach ($urls as $i => $url) { |
||
| 24 | $handles[$i] = \curl_init($url); |
||
| 25 | \curl_setopt($handles[$i], CURLOPT_RETURNTRANSFER, 1); |
||
| 26 | \curl_multi_add_handle($multiHandle, $handles[$i]); |
||
| 27 | } |
||
| 28 | |||
| 29 | $stillRunning = 0; |
||
| 30 | do { |
||
| 31 | \curl_multi_exec($multiHandle, $stillRunning); |
||
| 32 | } while ($stillRunning > 0); |
||
| 33 | |||
| 34 | foreach ($handles as $i => $handle) { |
||
| 35 | $result[$i] = \json_decode(\curl_multi_getcontent($handle), true); |
||
| 36 | \curl_multi_remove_handle($multiHandle, $handle); |
||
| 37 | } |
||
| 38 | |||
| 39 | \curl_multi_close($multiHandle); |
||
| 40 | |||
| 41 | return $result; |
||
| 42 | } |
||
| 44 |