Skip to content

Add --summary-only flag to output only summary in the text format report #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/cli/Arguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ final class Arguments
*/
private $text;

/**
* @var bool
*/
private $textSummaryOnly;

/**
* @var ?string
*/
Expand All @@ -106,7 +111,12 @@ final class Arguments
*/
private $pathPrefix;

public function __construct(?string $command, ?string $script, ?string $directory, ?string $coverage, ?string $patch, ?string $configuration, array $include, bool $pathCoverage, bool $addUncovered, bool $processUncovered, ?string $clover, ?string $cobertura, ?string $crap4j, ?string $html, ?string $php, ?string $text, ?string $xml, ?string $pathPrefix, bool $help, bool $version)
/**
* @var ?string
*/
private $cobertura;

public function __construct(?string $command, ?string $script, ?string $directory, ?string $coverage, ?string $patch, ?string $configuration, array $include, bool $pathCoverage, bool $addUncovered, bool $processUncovered, ?string $clover, ?string $cobertura, ?string $crap4j, ?string $html, ?string $php, ?string $text, bool $textSummaryOnly, ?string $xml, ?string $pathPrefix, bool $help, bool $version)
{
$this->command = $command;
$this->script = $script;
Expand All @@ -124,6 +134,7 @@ public function __construct(?string $command, ?string $script, ?string $director
$this->html = $html;
$this->php = $php;
$this->text = $text;
$this->textSummaryOnly = $textSummaryOnly;
$this->xml = $xml;
$this->pathPrefix = $pathPrefix;
$this->help = $help;
Expand Down Expand Up @@ -210,6 +221,11 @@ public function text(): ?string
return $this->text;
}

public function textSummaryOnly(): bool
{
return $this->textSummaryOnly;
}

public function xml(): ?string
{
return $this->xml;
Expand Down
9 changes: 9 additions & 0 deletions src/cli/ArgumentsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class ArgumentsBuilder
'html=',
'php=',
'text=',
'summary-only',
'xml=',
],
'arguments' => [
Expand All @@ -44,6 +45,7 @@ final class ArgumentsBuilder
'html=',
'php=',
'text=',
'summary-only',
'xml=',
],
'arguments' => [
Expand Down Expand Up @@ -135,6 +137,7 @@ public function build(array $argv): Arguments
$html = null;
$php = null;
$text = null;
$textSummaryOnly = false;
$xml = null;
$pathPrefix = null;
$help = false;
Expand Down Expand Up @@ -197,6 +200,11 @@ public function build(array $argv): Arguments

break;

case '--summary-only':
$textSummaryOnly = true;

break;

case '--xml':
$xml = $option[1];

Expand Down Expand Up @@ -238,6 +246,7 @@ public function build(array $argv): Arguments
$html,
$php,
$text,
$textSummaryOnly,
$xml,
$pathPrefix,
$help,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function handleReports(CodeCoverage $coverage, Arguments $arguments):
if ($arguments->text()) {
print 'Generating code coverage report in text format ... ';

$writer = new TextReport;
$writer = new TextReport(50, 90, false, $arguments->textSummaryOnly());

file_put_contents(
$arguments->text(),
Expand Down
1 change: 1 addition & 0 deletions src/cli/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function run(Arguments $arguments): int
--html <directory> Generate code coverage report in HTML format
--php <file> Export php-code-coverage object
--text <file> Generate code coverage report in text format
--summary-only Output only summary in the text format report
--xml <directory> Generate code coverage report in PHPUnit XML format

Options for "phpcov patch-coverage":
Expand Down
1 change: 1 addition & 0 deletions tests/end-to-end/help/help.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Options common for both "phpcov execute" and "phpcov merge":
--html <directory> Generate code coverage report in HTML format
--php <file> Export php-code-coverage object
--text <file> Generate code coverage report in text format
--summary-only Output only summary in the text format report
--xml <directory> Generate code coverage report in PHPUnit XML format

Options for "phpcov patch-coverage":
Expand Down
1 change: 1 addition & 0 deletions tests/end-to-end/help/help2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Options common for both "phpcov execute" and "phpcov merge":
--html <directory> Generate code coverage report in HTML format
--php <file> Export php-code-coverage object
--text <file> Generate code coverage report in text format
--summary-only Output only summary in the text format report
--xml <directory> Generate code coverage report in PHPUnit XML format

Options for "phpcov patch-coverage":
Expand Down