Completed
Push — develop ( f10e50...4f888d )
by Alec
03:20
created

ProfilerReport   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 39
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A __toString() 0 9 3
A getReports() 0 3 1
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 2
    public function getReports(): array
23
    {
24 2
        return $this->reports;
25
    }
26
27
    /**
28
     * ProfilerReport constructor.
29
     * @param Profiler $reportable
30
     */
31 5
    public function __construct(Profiler $reportable)
32
    {
33 5
        foreach ($reportable->getCounters() as $counter) {
34 5
            $this->reports[static::_COUNTERS][$counter->getName()] = $counter->report();
35
        }
36 5
        foreach ($reportable->getTimers() as $timer) {
37 5
            $this->reports[static::_TIMERS][$timer->getName()] = $timer->report();
38
        }
39 5
    }
40
41
    /**
42
     * @return string
43
     */
44 1
    public function __toString(): string
45
    {
46 1
        $r = '';
47 1
        foreach ($this->reports as $reports) {
48 1
            foreach ($reports as $report) {
49 1
                $r .= $report;
50
            }
51
        }
52 1
        return $r;
53
    }
54
}
55