lib/Http/Client.php
function upload(string $coverage, Configuration $configuration = null): void {
    $report = trim($coverage);
    if (!mb_strlen($report)) throw new \InvalidArgumentException('The specified coverage report is empty.');

    $job = null;
    $isClover = mb_substr($report, 0, 5) == '<?xml' || mb_substr($report, 0, 10) == '<coverage';
    if ($isClover) $job = Clover::parseReport($report);
    else {
      $token = mb_substr($report, 0, 3);
      if ($token == 'TN:' || $token == 'SF:') $job = Lcov::parseReport($report);
    }

    if (!$job) throw new \InvalidArgumentException('The specified coverage format is not supported.');
    $this->updateJob($job, $configuration ?? Configuration::loadDefaults());
    if (!$job->getRunAt()) $job->setRunAt(new \DateTime);

    try {
      which('git');
      $git = GitData::fromRepository();
      $branch = ($gitData = $job->getGit()) ? $gitData->getBranch() : '';
      if ($git->getBranch() == 'HEAD' && mb_strlen($branch)) $git->setBranch($branch);
      $job->setGit($git);
    }

    catch (FinderException $e) {}
    $this->uploadJob($job);
  }
function upload(string $coverage, Configuration $configuration = null): void {
    $report = trim($coverage);
    if (!mb_strlen($report)) throw new \InvalidArgumentException('The specified coverage report is empty.');

    $job = null;
    $isClover = mb_substr($report, 0, 5) == '<?xml' || mb_substr($report, 0, 10) == '<coverage';
    if ($isClover) $job = Clover::parseReport($report);
    else {
      $token = mb_substr($report, 0, 3);
      if ($token == 'TN:' || $token == 'SF:') $job = Lcov::parseReport($report);
    }

    if (!$job) throw new \InvalidArgumentException('The specified coverage format is not supported.');
    $this->updateJob($job, $configuration ?? Configuration::loadDefaults());
    if (!$job->getRunAt()) $job->setRunAt(new \DateTime);

    try {
      which('git');
      $git = GitData::fromRepository();
      $branch = ($gitData = $job->getGit()) ? $gitData->getBranch() : '';
      if ($git->getBranch() == 'HEAD' && mb_strlen($branch)) $git->setBranch($branch);
      $job->setGit($git);
    }

    catch (FinderException $e) {}
    $this->uploadJob($job);
  }
function upload ( string $ coverage , Configuration $ configuration = null ) : void { $ report = trim ( $ coverage ) ; if ( ! mb_strlen ( $ report ) ) throw new \ InvalidArgumentException ( 'The specified coverage report is empty.' ) ; $ job = null ; $ isClover = mb_substr ( $ report , 0 , 5 ) == '<?xml' || mb_substr ( $ report , 0 , 10 ) == '<coverage' ; if ( $ isClover ) $ job = Clover :: parseReport ( $ report ) ; else { $ token = mb_substr ( $ report , 0 , 3 ) ; if ( $ token == 'TN:' || $ token == 'SF:' ) $ job = Lcov :: parseReport ( $ report ) ; } if ( ! $ job ) throw new \ InvalidArgumentException ( 'The specified coverage format is not supported.' ) ; $ this -> updateJob ( $ job , $ configuration ?? Configuration :: loadDefaults ( ) ) ; if ( ! $ job -> getRunAt ( ) ) $ job -> setRunAt ( new \ DateTime ) ; try { which ( 'git' ) ; $ git = GitData :: fromRepository ( ) ; $ branch = ( $ gitData = $ job -> getGit ( ) ) ? $ gitData -> getBranch ( ) : '' ; if ( $ git -> getBranch ( ) == 'HEAD' && mb_strlen ( $ branch ) ) $ git -> setBranch ( $ branch ) ; $ job -> setGit ( $ git ) ; } catch ( FinderException $ e ) { } $ this -> uploadJob ( $ job ) ; }
Uploads the specified code coverage report to the Coveralls service.
@param string $coverage A coverage report.
@param Configuration $configuration The environment settings.
@throws \InvalidArgumentException The specified coverage report is empty or its format is not supported.
Uploads the specified code coverage report to the Coveralls service .