Passed
Push — master ( 4bff04...8ad0e5 )
by Alec
03:06
created

TimerReport   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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