ProfilerReport   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
eloc 10
dl 0
loc 42
ccs 13
cts 13
cp 1
rs 10
c 5
b 1
f 1
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A extractDataFrom() 0 8 4
A getReports() 0 3 1
A getCountersReports() 0 3 1
A getTimersReports() 0 3 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