ProfilerReport::getCountersReports()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools\Reports;
4
5
use AlecRabbit\Reports\Core\AbstractReport;
6
use AlecRabbit\Reports\Core\AbstractReportable;
7
use AlecRabbit\Tools\Contracts\Strings;
8
use AlecRabbit\Tools\Profiler;
9
10
class ProfilerReport extends AbstractReport implements Strings
11
{
12
    /** @var array */
13
    private $reports = [];
14
15
    /**
16
     * @return array
17
     */
18 1
    public function getReports(): array
19
    {
20 1
        return $this->reports;
21
    }
22
23
    /** {@inheritDoc}
24
     * @throws \Exception
25
     */
26 3
    protected function extractDataFrom(AbstractReportable $reportable = null): void
27
    {
28 3
        if ($reportable instanceof Profiler) {
29 3
            foreach ($reportable->getCounters() as $counter) {
30 3
                $this->reports[self::COUNTERS][$counter->getName()] = $counter->report();
31
            }
32 3
            foreach ($reportable->getTimers() as $timer) {
33 3
                $this->reports[self::TIMERS][$timer->getName()] = $timer->report();
34
            }
35
        }
36 3
    }
37
38
    /**
39
     * @return array
40
     */
41 3
    public function getCountersReports(): array
42
    {
43 3
        return $this->reports[self::COUNTERS];
44
    }
45
46
    /**
47
     * @return array
48
     */
49 3
    public function getTimersReports(): array
50
    {
51 3
        return $this->reports[self::TIMERS];
52
    }
53
}
54