Passed
Push — master ( 3c333b...51dbda )
by Alec
01:37
created

AbstractFormatter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A assertOptions() 0 5 3
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Accessories\Contracts;
4
5
use function AlecRabbit\typeOf;
6
7
abstract class AbstractFormatter implements FormatterInterface
8
{
9
    /** @var int */
10
    protected $options = 0;
11
12
    /**
13
     * @param mixed $options
14
     */
15 9
    public function __construct($options = null)
16
    {
17 9
        $this->assertOptions($options);
18 7
    }
19
20
    /**
21
     * @param mixed $options
22
     */
23 9
    protected function assertOptions($options): void
24
    {
25 9
        if (null !== $options && !is_int($options)) {
26 2
            throw new \RuntimeException(
27 2
                'Options for ' . __CLASS__ . ' constructor should be int, "' . typeOf($options) . '" given.'
28
            );
29
        }
30 7
    }
31
}
32