Completed
Push — develop ( fe1195...b733eb )
by Alec
05:48
created

ProfilerReport::__toString()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 0
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * User: alec
4
 * Date: 01.12.18
5
 * Time: 17:36
6
 */
7
8
namespace AlecRabbit\Tools\Reports;
9
10
use AlecRabbit\Tools\Contracts\StringsInterface;
11
use AlecRabbit\Tools\Profiler;
12
use AlecRabbit\Tools\Reports\Base\Report;
13
14
class ProfilerReport extends Report implements StringsInterface
15
{
16
    /** @var array */
17
    private $reports = [];
18
19
    /**
20
     * @return array
21
     */
22 4
    public function getReports(): array
23
    {
24 4
        return $this->reports;
25
    }
26
27
    /**
28
     * ProfilerReport constructor.
29
     * @param Profiler $profiler
30
     */
31 6
    public function __construct(Profiler $profiler)
32
    {
33 6
        foreach ($profiler->getCounters() as $counter) {
34 6
            $this->reports[static::_COUNTERS][$counter->getName()] = $counter->getReport();
35
        }
36 6
        foreach ($profiler->getTimers() as $timer) {
37 6
            $this->reports[static::_TIMERS][$timer->getName()] = $timer->getReport();
38
        }
39 6
        parent::__construct();
40 6
    }
41
}
42