Hirak\Prestissimo\Prefetcher::fetchAll PHP Method

fetchAll() public method

public fetchAll ( Composer\IO\IOInterface $io, array $requests )
$io Composer\IO\IOInterface
$requests array
    public function fetchAll(IO\IOInterface $io, array $requests)
    {
        $successCnt = $failureCnt = 0;
        $totalCnt = count($requests);
        $multi = new CurlMulti();
        $multi->setRequests($requests);
        try {
            do {
                $multi->setupEventLoop();
                $multi->wait();
                $result = $multi->getFinishedResults();
                $successCnt += $result['successCnt'];
                $failureCnt += $result['failureCnt'];
                foreach ($result['urls'] as $url) {
                    $io->writeError("    <comment>{$successCnt}/{$totalCnt}</comment>:\t{$url}", true, IO\IOInterface::VERBOSE);
                }
            } while ($multi->remain());
        } catch (FetchException $e) {
            // do nothing
        }
        $skippedCnt = $totalCnt - $successCnt - $failureCnt;
        $io->writeError("    Finished: <comment>success: {$successCnt}, skipped: {$skippedCnt}, failure: {$failureCnt}, total: {$totalCnt}</comment>", true, IO\IOInterface::VERBOSE);
    }

Usage Example

コード例 #1
0
ファイル: PrefetcherTest.php プロジェクト: DQNEO/prestissimo
 public function testFetchAllOnSuccess()
 {
     $reqp = $this->prophesize('Hirak\\Prestissimo\\CopyRequest');
     $reqp->getCurlOptions()->willReturn(array(CURLOPT_URL => 'file://' . __DIR__ . '/test.txt', CURLOPT_FILE => tmpfile()));
     $reqp->makeSuccess()->willReturn(null);
     $reqp->getMaskedURL()->willReturn('file://' . __DIR__ . '/test.txt');
     $this->iop->writeError(arg::type('string'))->shouldBeCalled();
     $fetcher = new Prefetcher();
     $fetcher->fetchAll($this->iop->reveal(), array($reqp->reveal()));
 }
All Usage Examples Of Hirak\Prestissimo\Prefetcher::fetchAll