Passed
Push — master ( ff2740...d05a86 )
by Alec
03:15 queued 13s
created

ACharPalette::getSequence()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Core\Palette\A;
6
7
use AlecRabbit\Spinner\Core\Contract\ICharFrame;
8
use AlecRabbit\Spinner\Core\Palette\Contract\ICharPalette;
9
use AlecRabbit\Spinner\Core\Palette\Contract\IPaletteMode;
10
use AlecRabbit\Spinner\Core\Palette\Contract\IPaletteOptions;
11
use AlecRabbit\Spinner\Core\Palette\PaletteOptions;
0 ignored issues
show
Bug introduced by
The type AlecRabbit\Spinner\Core\Palette\PaletteOptions 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 Traversable;
13
14
abstract class ACharPalette extends APalette implements ICharPalette
15
{
16
    /**
17
     * @return Traversable<ICharFrame>
18
     */
19
    protected function getEntries(?IPaletteMode $mode = null): Traversable
20
    {
21
        /** @var string|ICharFrame $element */
22
        foreach ($this->sequence() as $element) {
23
            if ($element instanceof ICharFrame) {
24
                yield $element;
25
                continue;
26
            }
27
            yield $this->createFrame($element);
28
        }
29
    }
30
31
    /**
32
     * @return Traversable<string|ICharFrame>
33
     */
34
    abstract protected function sequence(): Traversable;
35
36
    abstract protected function createFrame(string $element): ICharFrame;
37
38
    protected function getOptions(?IPaletteMode $mode = null): IPaletteOptions
39
    {
40
        $this->options =
41
            new PaletteOptions(
42
                interval: $this->options->getInterval() ?? $this->getInterval(),
43
                reversed: $this->options->getReversed(),
44
            );
45
46
        return parent::getOptions($mode);
47
    }
48
49
    protected function getInterval(): ?int
50
    {
51
        return 100;
52
    }
53
}
54