Passed
Push — master ( 34c1e4...428dea )
by Alec
03:16
created

BenchmarkReportFormatter::getString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Tools\Reports\Formatters;
6
7
use AlecRabbit\Tools\Internal\BenchmarkFunction;
8
use AlecRabbit\Tools\Reports\BenchmarkReport;
9
10
class BenchmarkReportFormatter extends ReportFormatter
11
{
12
    /** @var BenchmarkReport */
13
    protected $report;
14
15
    /**
16
     * {@inheritdoc}
17
     */
18 4
    public function getString(): string
19
    {
20 4
        $r = 'Benchmark:' . PHP_EOL;
21
        /** @var BenchmarkFunction $function */
22 4
        foreach ($this->report->getFunctions() as $name => $function) {
23 4
            $r .= (new  BenchmarkFunctionFormatter($function))->getString();
24
        }
25
        return
26 4
            $r . PHP_EOL .
27 4
            $this->report->getMemoryUsageReport() . PHP_EOL .
28 4
            $this->report->getProfiler()->getReport();
29
    }
30
}
31