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

CharFrameCollectionRenderer::assertEntryArray()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 32
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 20
nc 5
nop 1
dl 0
loc 32
rs 8.6666
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