Passed
Push — master ( b6b513...1a5d0e )
by Alec
01:45
created

AbstractFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 22
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A preparedException() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Traits\ForReports\Core;
4
5
use AlecRabbit\Traits\ForReports\Contracts\FormatterInterface;
6
7
abstract class AbstractFormatter implements FormatterInterface
8
{
9
    /** @var int */
10
    protected $options = 0;
11
12
    /** {@inheritDoc} */
13
    public function __construct(?int $options = null)
14
    {
15
        $this->options = $options ?? 0;
16
    }
17
18
    abstract public function process(Formattable $data): string;
19
20
    /**
21
     * @param Formattable $data
22
     * @param string $class
23
     * @return \Throwable
24
     */
25
    protected function preparedException(Formattable $data, string $class): \Throwable
26
    {
27
        return
28
            new \InvalidArgumentException($class . ' expected, ' . get_class($data) . ' given');
29
    }
30
}
31