Test Failed
Push — master ( 772f18...8c594b )
by Alec
03:05
created

TimerReport::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 17
nc 2
nop 0
dl 0
loc 21
ccs 16
cts 16
cp 1
crap 2
rs 9.7
c 0
b 0
f 0
1
<?php
2
/**
3
 * User: alec
4
 * Date: 29.11.18
5
 * Time: 21:02
6
 */
7
8
namespace AlecRabbit\Tools\Reports;
9
10
use AlecRabbit\Tools\Reports\Base\Report;
11
use AlecRabbit\Tools\Timer;
12
use AlecRabbit\Tools\Traits\TimerFields;
13
14
class TimerReport extends Report
15
{
16
    use TimerFields;
17
18
    /**
19
     * TimerReport constructor.
20
     * @param Timer $timer
21
     */
22
    public function __construct(Timer $timer)
23
    {
24 7
        try {
25
            $count = $timer->getCount();
26 7
            $this->name = $timer->getName();
27 7
            $this->previous = $timer->getPrevious();
28 7
            $this->creation = $timer->getCreation();
29 7
            $this->start = $timer->getStart();
30 7
            $this->elapsed = $timer->getElapsed();
31 7
            $this->stopped = $timer->isStopped();
32 7
            $this->currentValue = $timer->getLastValue();
33 7
            $this->minValueIteration = $timer->getMinValueIteration();
34 7
            $this->maxValueIteration = $timer->getMaxValueIteration();
35 7
            $this->avgValue = $timer->getAverageValue();
36 7
            $this->minValue = ($count === 1) ? $timer->getLastValue() : $timer->getMinValue();
37 7
            $this->maxValue = $timer->getMaxValue();
38 7
            $this->count = $count;
39 7
        } catch (\Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
40 7
        }
41
42
        parent::__construct($timer);
43
44
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
45 1
46
}
47