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

Report   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A wrongReportable() 0 3 1
A __toString() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools\Reports\Core;
4
5
use AlecRabbit\Tools\AbstractCounter;
6
use AlecRabbit\Tools\Reports\Contracts\ReportableInterface;
7
use AlecRabbit\Tools\Reports\Contracts\ReportInterface;
8
use AlecRabbit\Tools\Reports\Formatters\Contracts\FormatterInterface;
9
use function AlecRabbit\typeOf;
10
11
abstract class Report implements ReportInterface
12
{
13
    abstract protected static function getFormatter(): FormatterInterface;
14
15
    abstract public function buildOn(ReportableInterface $reportable): ReportInterface;
16
17
    /** {@inheritdoc} */
18
    public function __toString(): string
19
    {
20
        return
21
            static::getFormatter()->process($this);
22
    }
23
24
    /**
25
     * @param string $expected
26
     * @param ReportableInterface $reportable
27
     */
28
    protected function wrongReportable(string $expected, ReportableInterface $reportable): void
29
    {
30
        throw new \RuntimeException($expected . ' instance expected ' . typeOf($reportable) . ' given');
31
    }
32
}
33