Completed
Push — develop ( fe1195...b733eb )
by Alec
05:48
created

TimerReport   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 29
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 3
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