Completed
Push — develop ( b733eb...69cb61 )
by Alec
06:31
created

TimerReport::__construct()   A

Complexity

Conditions 3
Paths 14

Size

Total Lines 21
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 17
nc 14
nop 1
dl 0
loc 21
ccs 17
cts 17
cp 1
crap 3
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 10
    public function __construct(Timer $timer)
23
    {
24 10
        $this->name = $timer->getName();
25 10
        $this->creation = $timer->getCreation();
26
        try {
27 10
            $count = $timer->getCount();
28 10
            $this->previous = $timer->getPrevious();
29 9
            $this->start = $timer->getStart();
30 9
            $this->elapsed = $timer->getElapsed();
31 9
            $this->stopped = $timer->isStopped();
32 9
            $this->currentValue = $timer->getLastValue();
33 9
            $this->minValueIteration = $timer->getMinValueIteration();
34 9
            $this->maxValueIteration = $timer->getMaxValueIteration();
35 9
            $this->avgValue = $timer->getAverageValue();
36 9
            $this->minValue = ($count === 1) ? $timer->getLastValue() : $timer->getMinValue();
37 9
            $this->maxValue = $timer->getMaxValue();
38 9
            $this->count = $count;
39 2
        } catch (\Throwable $e) {
40
            // no further action
41
        }
42 10
        parent::__construct();
43 10
    }
44
}
45