|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace AlecRabbit\Reports; |
|
4
|
|
|
|
|
5
|
|
|
use AlecRabbit\Counters\Core\AbstractCounter; |
|
6
|
|
|
use AlecRabbit\Counters\Core\Traits\ExtendedCounterFields; |
|
7
|
|
|
use AlecRabbit\Counters\ExtendedCounter; |
|
8
|
|
|
use AlecRabbit\Formatters\Contracts\CounterReportFormatterInterface; |
|
9
|
|
|
use AlecRabbit\Formatters\ExtendedCounterReportFormatter; |
|
10
|
|
|
use AlecRabbit\Reports\Contracts\ReportableInterface; |
|
11
|
|
|
use AlecRabbit\Reports\Contracts\ReportInterface; |
|
12
|
|
|
|
|
13
|
|
|
class ExtendedCounterReport extends SimpleCounterReport |
|
14
|
|
|
{ |
|
15
|
|
|
use ExtendedCounterFields; |
|
16
|
|
|
|
|
17
|
|
|
protected static function createFormatter(): CounterReportFormatterInterface |
|
18
|
|
|
{ |
|
19
|
|
|
return new ExtendedCounterReportFormatter(); |
|
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
|
7 |
|
$this->name = $counter->getName(); |
|
32
|
|
|
$this->value = $counter->getValue(); |
|
33
|
7 |
|
$this->step = $counter->getStep(); |
|
34
|
7 |
|
$this->started = $counter->isStarted(); |
|
35
|
7 |
|
$this->initialValue = $counter->getInitialValue(); |
|
36
|
7 |
|
$this->bumped = $counter->getBumped(); |
|
37
|
7 |
|
$this->max = $counter->getMax(); |
|
38
|
7 |
|
$this->min = $counter->getMin(); |
|
39
|
7 |
|
$this->path = $counter->getPath(); |
|
40
|
7 |
|
$this->length = $counter->getLength(); |
|
41
|
7 |
|
$this->diff = $counter->getDiff(); |
|
42
|
7 |
|
$this->bumpedBack = $counter->getBumpedBack(); |
|
43
|
7 |
|
return $this; |
|
44
|
7 |
|
} |
|
45
|
7 |
|
throw new \InvalidArgumentException( |
|
46
|
7 |
|
AbstractCounter::class . ' expected, ' . get_class($counter) . ' given.' |
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
} |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|