1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AlecRabbit\Spinner\Core\Palette\A; |
6
|
|
|
|
7
|
|
|
use AlecRabbit\Spinner\Contract\Mode\StylingMethodMode; |
8
|
|
|
use AlecRabbit\Spinner\Core\Contract\IStyleFrame; |
9
|
|
|
use AlecRabbit\Spinner\Core\Palette\Contract\IPaletteMode; |
10
|
|
|
use AlecRabbit\Spinner\Core\Palette\Contract\IPaletteOptions; |
11
|
|
|
use AlecRabbit\Spinner\Core\Palette\Contract\IStylePalette; |
12
|
|
|
use AlecRabbit\Spinner\Core\Palette\PaletteOptions; |
|
|
|
|
13
|
|
|
use AlecRabbit\Spinner\Core\StyleFrame; |
|
|
|
|
14
|
|
|
use Traversable; |
15
|
|
|
|
16
|
|
|
abstract class AStylePalette extends APalette implements IStylePalette |
17
|
|
|
{ |
18
|
|
|
protected function getOptions(?IPaletteMode $mode = null): IPaletteOptions |
19
|
|
|
{ |
20
|
|
|
$interval = $this->options->getInterval() ?? $this->getInterval($this->extractStylingMode($mode)); |
21
|
|
|
|
22
|
|
|
$this->options = |
23
|
|
|
new PaletteOptions( |
24
|
|
|
interval: $interval, |
25
|
|
|
reversed: $this->options->getReversed(), |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
return parent::getOptions($mode); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function getInterval(StylingMethodMode $stylingMode): ?int |
32
|
|
|
{ |
33
|
|
|
return match ($stylingMode) { |
34
|
|
|
StylingMethodMode::ANSI8 => 1000, |
35
|
|
|
StylingMethodMode::ANSI24 => 100, |
36
|
|
|
default => null, |
37
|
|
|
}; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function extractStylingMode(?IPaletteMode $options): StylingMethodMode |
41
|
|
|
{ |
42
|
|
|
return $options?->getStylingMode() ?? StylingMethodMode::NONE; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return Traversable<IStyleFrame> |
47
|
|
|
*/ |
48
|
|
|
protected function getEntries(?IPaletteMode $mode = null): Traversable |
49
|
|
|
{ |
50
|
|
|
$stylingMode = $this->extractStylingMode($mode); |
51
|
|
|
|
52
|
|
|
yield from match ($stylingMode) { |
53
|
|
|
StylingMethodMode::NONE => $this->noStyleFrames(), |
54
|
|
|
StylingMethodMode::ANSI4 => $this->ansi4StyleFrames(), |
55
|
|
|
StylingMethodMode::ANSI8 => $this->ansi8StyleFrames(), |
56
|
|
|
StylingMethodMode::ANSI24 => $this->ansi24StyleFrames(), |
57
|
|
|
}; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Traversable<IStyleFrame> |
62
|
|
|
*/ |
63
|
|
|
protected function noStyleFrames(): Traversable |
64
|
|
|
{ |
65
|
|
|
yield from [ |
66
|
|
|
$this->createFrame('%s'), |
67
|
|
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function createFrame(string $element): IStyleFrame |
71
|
|
|
{ |
72
|
|
|
return new StyleFrame($element, 0); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return Traversable<IStyleFrame> |
77
|
|
|
*/ |
78
|
|
|
abstract protected function ansi4StyleFrames(): Traversable; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return Traversable<IStyleFrame> |
82
|
|
|
*/ |
83
|
|
|
abstract protected function ansi8StyleFrames(): Traversable; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @return Traversable<IStyleFrame> |
87
|
|
|
*/ |
88
|
|
|
abstract protected function ansi24StyleFrames(): Traversable; |
89
|
|
|
} |
90
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths