AWidget   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createFrame() 0 3 1
A getFrame() 0 8 1
A getInterval() 0 3 1
A __construct() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Core\Widget\A;
6
7
use AlecRabbit\Spinner\Contract\IFrame;
8
use AlecRabbit\Spinner\Contract\IInterval;
9
use AlecRabbit\Spinner\Contract\IObserver;
10
use AlecRabbit\Spinner\Core\A\ASubject;
11
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...
12
use AlecRabbit\Spinner\Core\Contract\ICharFrame;
13
use AlecRabbit\Spinner\Core\Widget\Contract\IWidget;
14
use AlecRabbit\Spinner\Core\Widget\Contract\IWidgetRevolver;
15
16
abstract class AWidget extends ASubject implements IWidget
17
{
18
    public function __construct(
19
        protected readonly IWidgetRevolver $widgetRevolver,
20
        protected readonly IFrame $leadingSpacer,
21
        protected readonly IFrame $trailingSpacer,
22
        ?IObserver $observer = null,
23
    ) {
24
        parent::__construct($observer);
25
    }
26
27
    public function getInterval(): IInterval
28
    {
29
        return $this->widgetRevolver->getInterval();
30
    }
31
32
    public function getFrame(?float $dt = null): ICharFrame
33
    {
34
        $widgetRevolverFrame = $this->widgetRevolver->getFrame($dt);
35
36
        return $this->createFrame(
37
            $this->leadingSpacer->getSequence() . $widgetRevolverFrame->getSequence(
38
            ) . $this->trailingSpacer->getSequence(),
39
            $this->leadingSpacer->getWidth() + $widgetRevolverFrame->getWidth() + $this->trailingSpacer->getWidth()
40
        );
41
    }
42
43
    protected function createFrame(string $sequence, int $width): ICharFrame
44
    {
45
        return new CharFrame($sequence, $width);
46
    }
47
}
48