Passed
Push — develop ( 0a2c3f...8e5858 )
by Alec
03:05
created

ExtendedCounterReport::getFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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 1
    public function buildOn(ReportableInterface $counter): ReportInterface
29
    {
30 1
        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 1
            $this->wrongReportable(ExtendedCounter::class, $counter);
45
        }
46
        return $this;
47
    }
48
}
49