Skip to content

Commit

Permalink
Merge pull request phpro#419 from jdecoster/master
Browse files Browse the repository at this point in the history
Fix divide by 0 warning
  • Loading branch information
Landerstraeten committed Nov 15, 2017
2 parents 7892b9f + 954e16e commit fef8bab
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Task/CloverCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public function run(ContextInterface $context)
$totalElements = (string)current($xml->xpath('/coverage/project/metrics/@elements'));
$checkedElements = (string)current($xml->xpath('/coverage/project/metrics/@coveredelements'));

if ((int)$totalElements === 0) {
return TaskResult::createSkipped($this, $context);
}

$coverage = round(($checkedElements / $totalElements) * 100, 2);

if ($coverage < $percentage) {
Expand Down

0 comments on commit fef8bab

Please sign in to comment.