WidgetRevolver   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
c 0
b 0
f 0
dl 0
loc 51
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A next() 0 6 1
A createFrame() 0 3 1
A __construct() 0 14 1
A getFrame() 0 7 1
A current() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Core\Widget;
6
7
use AlecRabbit\Spinner\Contract\IFrame;
8
use AlecRabbit\Spinner\Core\CharFrame;
0 ignored issues
show
Bug introduced by
The type AlecRabbit\Spinner\Core\CharFrame was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use AlecRabbit\Spinner\Core\Contract\ICharFrame;
10
use AlecRabbit\Spinner\Core\Contract\IIntervalComparator;
11
use AlecRabbit\Spinner\Core\Contract\ITolerance;
12
use AlecRabbit\Spinner\Core\IntervalComparator;
0 ignored issues
show
Bug introduced by
The type AlecRabbit\Spinner\Core\IntervalComparator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use AlecRabbit\Spinner\Core\Revolver\A\ARevolver;
14
use AlecRabbit\Spinner\Core\Revolver\Contract\IRevolver;
15
use AlecRabbit\Spinner\Core\Widget\Contract\IWidgetRevolver;
16
use AlecRabbit\Spinner\Exception\LogicException;
17
18
final class WidgetRevolver extends ARevolver implements IWidgetRevolver
19
{
20
    public function __construct(
21
        private readonly IRevolver $style,
22
        private readonly IRevolver $character,
23
        ITolerance $tolerance,
24
        IIntervalComparator $intervalComparator = new IntervalComparator(
25
        ), // FIXME (2023-11-21 17:34) [Alec Rabbit]: pass it as param it or better pass IInterval
26
    )
27
    {
28
        parent::__construct(
29
            $intervalComparator->smallest(
30
                $style->getInterval(),
31
                $character->getInterval(),
32
            ),
33
            $tolerance,
34
        );
35
    }
36
37
    public function getFrame(?float $dt = null): IFrame
38
    {
39
        $style = $this->style->getFrame($dt);
40
        $char = $this->character->getFrame($dt);
41
        return $this->createFrame(
42
            sprintf($style->getSequence(), $char->getSequence()),
43
            $style->getWidth() + $char->getWidth()
44
        );
45
    }
46
47
    private function createFrame(string $sequence, int $width): ICharFrame
48
    {
49
        return new CharFrame($sequence, $width);
50
    }
51
52
    // @codeCoverageIgnoreStart
53
    protected function next(?float $dt = null): void
54
    {
55
        throw new LogicException(
56
            sprintf(
57
                'Method %s() should never be called.',
58
                __METHOD__
59
            )
60
        );
61
    }
62
63
    protected function current(): IFrame
64
    {
65
        throw new LogicException(
66
            sprintf(
67
                'Method %s() should never be called.',
68
                __METHOD__
69
            )
70
        );
71
    }
72
    // @codeCoverageIgnoreEnd
73
}
74