Passed
Push — master ( 200d88...9b81d7 )
by Alec
02:43 queued 15s
created

CharFrameCollectionRenderer::refineNullableInt()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
// 10.03.23
5
6
namespace AlecRabbit\Spinner\Core;
7
8
use AlecRabbit\Spinner\Contract\IFrame;
9
use AlecRabbit\Spinner\Contract\IStyle;
10
use AlecRabbit\Spinner\Core\A\AFrameCollectionRenderer;
11
use AlecRabbit\Spinner\Core\Factory\FrameFactory;
12
use AlecRabbit\Spinner\Exception\InvalidArgumentException;
13
14
use function is_string;
15
16
final class CharFrameCollectionRenderer extends AFrameCollectionRenderer
17
{
18
    protected function createFrame(string|IStyle $entry): IFrame
19
    {
20
        if (!is_string($entry)) {
21
            throw new InvalidArgumentException(
22
                sprintf(
23
                    'Entry should be type of "string", "%s" given%s.',
24
                    get_debug_type($entry),
25
                    sprintf(', see "%s()"', __METHOD__),
26
                )
27
            );
28
        }
29
        return FrameFactory::create($entry, WidthDeterminer::determine($entry));
30
    }
31
}
32