Completed
Push — master ( c7a3c9...eed046 )
by Alec
16:25
created

Formatter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A wrongFormattableType() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Tools\Formatters\Core;
4
5
use AlecRabbit\Tools\Contracts\Strings;
6
use AlecRabbit\Tools\Formattable;
7
use AlecRabbit\Tools\Formatters\Contracts\FormatterInterface;
8
use function AlecRabbit\typeOf;
9
10
abstract class Formatter implements FormatterInterface, Strings
11
{
12
    /** {@inheritdoc} */
13
    abstract public function process(Formattable $formattable): string;
14
15
    /**
16
     * @param string $expected
17
     * @param Formattable $formattable
18
     * @throws \RuntimeException
19
     */
20
    protected function wrongFormattableType(string $expected, Formattable $formattable): void
21
    {
22
        throw new \RuntimeException(
23
            'Instance of [' . $expected . '] expected, [' . typeOf($formattable) . '] given.'
24
        );
25
    }
26
}
27