Test Setup Failed
Push — develop ( 7cd2b2...750858 )
by Alec
03:42
created

SimpleCounterReport   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildOn() 0 13 2
A getFormatter() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools\Reports;
4
5
use AlecRabbit\Tools\AbstractCounter;
6
use AlecRabbit\Tools\Contracts\CounterInterface;
7
use AlecRabbit\Tools\ExtendedCounter;
8
use AlecRabbit\Tools\Reports\Contracts\ReportableInterface;
9
use AlecRabbit\Tools\Reports\Contracts\ReportInterface;
10
use AlecRabbit\Tools\Reports\Core\Report;
11
use AlecRabbit\Tools\Reports\Formatters\Contracts\FormatterInterface;
12
use AlecRabbit\Tools\SimpleCounter;
13
use AlecRabbit\Tools\Traits\ExtendedCounterFields;
14
use AlecRabbit\Tools\Traits\SimpleCounterFields;
15
use function AlecRabbit\typeOf;
16
17
class SimpleCounterReport extends Report
18
{
19
    use SimpleCounterFields, SimpleCounterFields;
20
21
    protected static function getFormatter(): FormatterInterface
22
    {
23
        return Factory::getSimpleCounterReportFormatter();
24
    }
25
26
    /**
27
     * @param ReportableInterface $counter
28
     * @return ReportInterface
29
     * @throws \RuntimeException
30
     * @throws \Exception
31
     */
32
    public function buildOn(ReportableInterface $counter): ReportInterface
33
    {
34
        if ($counter instanceof SimpleCounter) {
35
            $this->name = $counter->getName();
36
            $this->value = $counter->getValue();
37
            $this->step = $counter->getStep();
38
            $this->started = $counter->isStarted();
39
            $this->initialValue = $counter->getInitialValue();
40
            $this->bumped = $counter->getBumped();
41
        } else {
42
            $this->wrongReportable(SimpleCounter::class, $counter);
43
        }
44
        return $this;
45
    }
46
}
47