Passed
Push — master ( 110e22...e67765 )
by Alec
02:51
created

ExtendedCounterReport::getFormatter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 2
    protected static function getFormatter(): FormatterInterface
18
    {
19 2
        return Factory::getExtendedCounterReportFormatter();
20
    }
21
22
    /**
23
     * @param ReportableInterface $counter
24
     * @return ReportInterface
25
     * @throws \RuntimeException
26
     * @throws \Exception
27
     */
28 17
    public function buildOn(ReportableInterface $counter): ReportInterface
29
    {
30 17
        if ($counter instanceof ExtendedCounter) {
31 17
            $this->name = $counter->getName();
32 17
            $this->value = $counter->getValue();
33 17
            $this->step = $counter->getStep();
34 17
            $this->started = $counter->isStarted();
35 17
            $this->initialValue = $counter->getInitialValue();
36 17
            $this->bumped = $counter->getBumped();
37 17
            $this->max = $counter->getMax();
38 17
            $this->min = $counter->getMin();
39 17
            $this->path = $counter->getPath();
40 17
            $this->length = $counter->getLength();
41 17
            $this->diff = $counter->getDiff();
42 17
            $this->bumpedBack = $counter->getBumpedBack();
43
        } else {
44 1
            $this->wrongReportable(ExtendedCounter::class, $counter);
45
        }
46 17
        return $this;
47
    }
48
}
49