Passed
Push — master ( 3dcb8c...c11c60 )
by Alec
01:42
created

AbstractFormatter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A errorMessage() 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 1
    public function __construct(?int $options = null)
14
    {
15 1
        $this->options = $options ?? 0;
16 1
    }
17
18
    abstract public function process(Formattable $data): string;
19
20
    /**
21
     * @param Formattable $data
22
     * @param string $class
23
     * @return string
24
     */
25 1
    protected function errorMessage(Formattable $data, string $class): string
26
    {
27
        return
28 1
            $class . ' expected, ' . get_class($data) . ' given.';
29
    }
30
}
31