Total Complexity | 11 |
Total Lines | 54 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php declare(strict_types=1); |
||
12 | class ProfilerReportFormatter extends AbstractFormatter |
||
13 | { |
||
14 | /** @var string */ |
||
15 | private $elapsed = ''; |
||
16 | |||
17 | /** {@inheritdoc} */ |
||
18 | 4 | public function format(Formattable $formattable): string |
|
19 | { |
||
20 | 4 | if ($formattable instanceof ProfilerReport) { |
|
21 | return |
||
22 | 3 | sprintf( |
|
23 | 3 | '%s%s%s', |
|
24 | 3 | $this->countersStrings($formattable), |
|
25 | 3 | $this->timersStrings($formattable), |
|
26 | 3 | $this->elapsed |
|
27 | ); |
||
28 | } |
||
29 | return |
||
30 | 1 | $this->errorMessage($formattable, ProfilerReport::class); |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param ProfilerReport $report |
||
35 | * @return string |
||
36 | */ |
||
37 | 3 | protected function countersStrings(ProfilerReport $report): string |
|
38 | { |
||
39 | 3 | $r = ''; |
|
40 | 3 | foreach ($report->getCountersReports() as $counterReport) { |
|
41 | 3 | if ($counterReport instanceof AbstractCounterReport && DEFAULT_NAME === $counterReport->getName()) { |
|
42 | 3 | $r .= $counterReport->isStarted() ? $counterReport : ''; |
|
43 | } else { |
||
44 | 1 | $r .= $counterReport; |
|
45 | } |
||
46 | } |
||
47 | 3 | return $r; |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param ProfilerReport $report |
||
52 | * @return string |
||
53 | */ |
||
54 | 3 | protected function timersStrings(ProfilerReport $report): string |
|
66 | } |
||
67 | } |
||
68 |