Completed
Push — develop ( fe1195...b733eb )
by Alec
05:48
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 8
    public function __construct(Timer $timer)
23
    {
24
        try {
25 8
            $count = $timer->getCount();
26 8
            $this->name = $timer->getName();
27 8
            $this->previous = $timer->getPrevious();
28 8
            $this->creation = $timer->getCreation();
29 8
            $this->start = $timer->getStart();
30 8
            $this->elapsed = $timer->getElapsed();
31 8
            $this->stopped = $timer->isStopped();
32 8
            $this->currentValue = $timer->getLastValue();
33 8
            $this->minValueIteration = $timer->getMinValueIteration();
34 8
            $this->maxValueIteration = $timer->getMaxValueIteration();
35 8
            $this->avgValue = $timer->getAverageValue();
36 8
            $this->minValue = ($count === 1) ? $timer->getLastValue() : $timer->getMinValue();
37 8
            $this->maxValue = $timer->getMaxValue();
38 8
            $this->count = $count;
39
        } catch (\Throwable $e) {
40
            // no further action
41
        }
42 8
        parent::__construct();
43 8
    }
44
}
45