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

BenchmarkReportFormatter::average()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
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