Test Failed
Push — develop ( f741b1...4c7784 )
by Alec
05:40
created

ProfilerReportFormatter   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B getString() 0 16 8
1
<?php
2
declare(strict_types=1);
3
4
namespace AlecRabbit\Tools\Reports\Formatters;
5
6
use AlecRabbit\Tools\Reports\CounterReport;
7
use AlecRabbit\Tools\Reports\ProfilerReport;
8
use AlecRabbit\Tools\Reports\TimerReport;
9
use const AlecRabbit\Traits\Constants\DEFAULT_NAME;
10
11
class ProfilerReportFormatter extends Formatter
12
{
13 7
    /** @var ProfilerReport */
14
    protected $report;
15 7
16
    public function getString(): string
17 3
    {
18
        $r = '';
19 3
        $elapsed = '';
20 3
        foreach ($this->report->getReports() as $reports) {
21 3
            foreach ($reports as $report) {
22 3
                if ($report instanceof TimerReport && DEFAULT_NAME === $report->getName()) {
23
                    $elapsed .= $report;
24
                } elseif ($report instanceof CounterReport && DEFAULT_NAME === $report->getName()) {
25 3
                    $r .= $report->isStarted() ? $report : '';
26
                } else {
27
                    $r .= $report;
28
                }
29
            }
30
        }
31
        return $r . $elapsed;
32
    }
33
}
34