Passed
Push — master ( 823aee...b9b37f )
by Alec
13:15 queued 12s
created

AFrameFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 1
A createSpace() 0 3 1
A createEmpty() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
// 10.03.23
5
6
namespace AlecRabbit\Spinner\Core\Factory\A;
7
8
use AlecRabbit\Spinner\Contract\IFrame;
9
use AlecRabbit\Spinner\Core\Factory\Contract\IFrameFactory;
10
use AlecRabbit\Spinner\Core\Frame;
11
use AlecRabbit\Spinner\Core\WidthDeterminer;
12
13
abstract class AFrameFactory implements IFrameFactory
14
{
15
    public static function create(string $sequence, ?int $width = null): IFrame
16
    {
17
        return
18
            new Frame(
19
                $sequence,
20
                $width ?? WidthDeterminer::determine($sequence)
21
            );
22
    }
23
24
    public static function createEmpty(): IFrame
25
    {
26
        return new Frame('', 0);
27
    }
28
29
    public static function createSpace(): IFrame
30
    {
31
        return new Frame(' ', 1);
32
    }
33
}
34