Completed
Push — master ( 6a7da5...1827cf )
by Alec
08:13 queued 02:32
created

ProfilerReport::__construct()   A

Complexity

Conditions 3
Paths 4

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 4
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
crap 3
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\Exception\InvalidStyleException;
11
use AlecRabbit\Tools\Contracts\StringsInterface;
12
use AlecRabbit\Tools\Profiler;
13
use AlecRabbit\Tools\Reports\Base\Report;
14
15
class ProfilerReport extends Report implements StringsInterface
16
{
17
    /** @var array */
18
    private $reports = [];
19
20
    /**
21
     * @return array
22
     */
23 4
    public function getReports(): array
24
    {
25 4
        return $this->reports;
26
    }
27
    
28
    /**
29
     * @return array
30
     */
31 2
    public function getCountersReports(): array
32
    {
33 2
        return $this->reports[self::COUNTERS];
34
    }
35
36
    /**
37
     * @return array
38
     */
39 2
    public function getTimersReports(): array
40
    {
41 2
        return $this->reports[self::TIMERS];
42
    }
43
44
    /**
45
     * ProfilerReport constructor.
46
     * @param Profiler $profiler
47
     */
48 5
    public function __construct(Profiler $profiler)
49
    {
50 5
        foreach ($profiler->getCounters() as $counter) {
51 5
            $this->reports[self::COUNTERS][$counter->getName()] = $counter->getReport();
52
        }
53 5
        foreach ($profiler->getTimers() as $timer) {
54 5
            $this->reports[self::TIMERS][$timer->getName()] = $timer->getReport();
55
        }
56 5
        parent::__construct();
57 5
    }
58
}
59