PhpCsFixer\Report\TextReporter::generate PHP Method

generate() public method

public generate ( PhpCsFixer\Report\ReportSummary $reportSummary )
$reportSummary PhpCsFixer\Report\ReportSummary
    public function generate(ReportSummary $reportSummary)
    {
        $output = '';
        $i = 0;
        foreach ($reportSummary->getChanged() as $file => $fixResult) {
            ++$i;
            $output .= sprintf('%4d) %s', $i, $file);
            if ($reportSummary->shouldAddAppliedFixers()) {
                $output .= $this->getAppliedFixers($reportSummary->isDecoratedOutput(), $fixResult);
            }
            $output .= $this->getDiff($reportSummary->isDecoratedOutput(), $fixResult);
            $output .= PHP_EOL;
        }
        return $output . $this->getFooter($reportSummary->getTime(), $reportSummary->getMemory(), $reportSummary->isDryRun());
    }

Usage Example

Exemplo n.º 1
0
    public function testGenerateComplexWithDecoratedOutput()
    {
        $expectedText = str_replace("\n", PHP_EOL, <<<'TEXT'
   1) someFile.php (<comment>some_fixer_name_here</comment>)
<comment>      ---------- begin diff ----------</comment>
this text is a diff ;)
<comment>      ----------- end diff -----------</comment>

   2) anotherFile.php (<comment>another_fixer_name_here</comment>)
<comment>      ---------- begin diff ----------</comment>
another diff here ;)
<comment>      ----------- end diff -----------</comment>


Checked all files in 1.234 seconds, 2.500 MB memory used

TEXT
);
        $this->assertSame($expectedText, $this->reporter->generate(ReportSummary::create()->setAddAppliedFixers(true)->setChanged(array('someFile.php' => array('appliedFixers' => array('some_fixer_name_here'), 'diff' => 'this text is a diff ;)'), 'anotherFile.php' => array('appliedFixers' => array('another_fixer_name_here'), 'diff' => 'another diff here ;)')))->setIsDecoratedOutput(true)->setIsDryRun(true)->setMemory(2.5 * 1024 * 1024)->setTime(1234)));
    }