Skip to content

Commit

Permalink
fix: warns about xdebug modes
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Oct 10, 2021
1 parent 04dcebf commit 1e011c7
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Support/Coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,36 @@ public static function getPath(): string
}

/**
* Runs true there is any code
* coverage driver available.
* Runs true there is any code coverage driver available.
*/
public static function isAvailable(): bool
{
return (new Runtime())->canCollectCodeCoverage();
}

/**
* If the user is using Xdebug.
*/
public static function usingXdebug(): bool
{
return (new Runtime())->hasXdebug();
}

/**
* Reports the code coverage report to the
* console and returns the result in float.
*/
public static function report(OutputInterface $output): float
{
if (!file_exists($reportPath = self::getPath())) {
if (self::usingXdebug()) {
$output->writeln(
" <fg=black;bg=yellow;options=bold> WARN </> Unable to get coverage using Xdebug. Did you set Xdebug's coverage mode?</>",
);

return 0.0;
}

throw ShouldNotHappen::fromMessage(sprintf('Coverage not found in path: %s.', $reportPath));
}

Expand Down

0 comments on commit 1e011c7

Please sign in to comment.