Test Failed
Push — master ( 2fcf63...a2b1bc )
by Alec
02:17
created

ExtendedCounterReport::buildOn()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 16
nc 2
nop 1
dl 0
loc 19
ccs 15
cts 15
cp 1
crap 2
rs 9.7333
c 0
b 0
f 0
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
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
50
}
51