1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace AlecRabbit\Tools\Reports; |
4
|
|
|
|
5
|
|
|
use AlecRabbit\Tools\ExtendedCounter; |
6
|
|
|
use AlecRabbit\Tools\Reports\Contracts\ReportableInterface; |
7
|
|
|
use AlecRabbit\Tools\Reports\Contracts\ReportInterface; |
8
|
|
|
use AlecRabbit\Tools\Reports\Core\Report; |
9
|
|
|
use AlecRabbit\Tools\Reports\Formatters\Contracts\FormatterInterface; |
10
|
|
|
use AlecRabbit\Tools\Traits\ExtendedCounterFields; |
11
|
|
|
use AlecRabbit\Tools\Traits\SimpleCounterFields; |
12
|
|
|
|
13
|
|
|
class ExtendedCounterReport extends Report |
14
|
|
|
{ |
15
|
|
|
use ExtendedCounterFields, SimpleCounterFields; |
16
|
|
|
|
17
|
|
|
protected static function getFormatter(): FormatterInterface |
18
|
|
|
{ |
19
|
|
|
return Factory::getExtendedCounterReportFormatter(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param ReportableInterface $counter |
24
|
|
|
* @return ReportInterface |
25
|
|
|
* @throws \RuntimeException |
26
|
|
|
* @throws \Exception |
27
|
|
|
*/ |
28
|
|
|
public function buildOn(ReportableInterface $counter): ReportInterface |
29
|
|
|
{ |
30
|
|
|
if ($counter instanceof ExtendedCounter) { |
31
|
|
|
$this->name = $counter->getName(); |
32
|
|
|
$this->value = $counter->getValue(); |
33
|
|
|
$this->step = $counter->getStep(); |
34
|
|
|
$this->started = $counter->isStarted(); |
35
|
|
|
$this->initialValue = $counter->getInitialValue(); |
36
|
|
|
$this->bumped = $counter->getBumped(); |
37
|
|
|
$this->max = $counter->getMax(); |
38
|
|
|
$this->min = $counter->getMin(); |
39
|
|
|
$this->path = $counter->getPath(); |
40
|
|
|
$this->length = $counter->getLength(); |
41
|
|
|
$this->diff = $counter->getDiff(); |
42
|
|
|
$this->bumpedBack = $counter->getBumpedBack(); |
43
|
|
|
} else { |
44
|
|
|
$this->wrongReportable(ExtendedCounter::class, $counter); |
45
|
|
|
} |
46
|
|
|
return $this; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|