1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace AlecRabbit\Spinner\Core; |
4
|
|
|
|
5
|
|
|
use AlecRabbit\Spinner\Core\Adapters\EchoOutputAdapter; |
|
|
|
|
6
|
|
|
use AlecRabbit\Spinner\Core\Adapters\StdErrOutputAdapter; |
7
|
|
|
use AlecRabbit\Spinner\Core\Contracts\Frames; |
8
|
|
|
use AlecRabbit\Spinner\Core\Contracts\SpinnerInterface; |
9
|
|
|
use AlecRabbit\Spinner\Core\Contracts\OutputInterface; |
10
|
|
|
use AlecRabbit\Spinner\Core\Contracts\Styles; |
11
|
|
|
use AlecRabbit\Spinner\Settings\Contracts\Defaults; |
12
|
|
|
use AlecRabbit\Spinner\Settings\Settings; |
13
|
|
|
use function AlecRabbit\typeOf; |
14
|
|
|
|
15
|
|
|
abstract class SpinnerCore implements SpinnerInterface |
16
|
|
|
{ |
17
|
|
|
protected const EMPTY_STRING = Defaults::EMPTY_STRING; |
18
|
|
|
|
19
|
|
|
protected const INTERVAL = Defaults::DEFAULT_INTERVAL; |
20
|
|
|
protected const FRAMES = Frames::BASE; |
21
|
|
|
protected const STYLES = Styles::STYLING_DISABLED; |
22
|
|
|
|
23
|
|
|
/** @var null|OutputInterface */ |
24
|
|
|
protected $output; |
25
|
|
|
/** @var bool */ |
26
|
|
|
protected $enabled; |
27
|
|
|
/** @var float */ |
28
|
|
|
protected $interval; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @param null|false|OutputInterface $output |
32
|
|
|
* @return null|OutputInterface |
33
|
|
|
*/ |
34
|
29 |
|
protected function refineOutput($output): ?OutputInterface |
35
|
|
|
{ |
36
|
29 |
|
Sentinel::assertOutput($output); |
37
|
27 |
|
if (false === $output) { |
38
|
23 |
|
return null; |
39
|
|
|
} |
40
|
4 |
|
return $output ?? new StdErrOutputAdapter(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** {@inheritDoc} */ |
44
|
1 |
|
public function disable(): SpinnerInterface |
45
|
|
|
{ |
46
|
1 |
|
$this->enabled = false; |
47
|
1 |
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** {@inheritDoc} */ |
51
|
1 |
|
public function enable(): SpinnerInterface |
52
|
|
|
{ |
53
|
1 |
|
$this->enabled = true; |
54
|
1 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** {@inheritDoc} */ |
58
|
1 |
|
public function isActive(): bool |
59
|
|
|
{ |
60
|
1 |
|
return $this->enabled; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param null|string|Settings $settings |
65
|
|
|
* @return Settings |
66
|
|
|
*/ |
67
|
27 |
|
protected function refineSettings($settings): Settings |
68
|
|
|
{ |
69
|
27 |
|
Sentinel::assertSettings($settings); |
70
|
26 |
|
if (\is_string($settings)) { |
71
|
|
|
return |
72
|
19 |
|
$this->defaultSettings()->setMessage($settings); |
73
|
|
|
} |
74
|
7 |
|
if ($settings instanceof Settings) { |
75
|
4 |
|
return $this->defaultSettings()->merge($settings); |
76
|
|
|
} |
77
|
|
|
return |
78
|
3 |
|
$this->defaultSettings(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** {@inheritDoc} */ |
82
|
6 |
|
public function interval(): float |
83
|
|
|
{ |
84
|
6 |
|
return $this->interval; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return Settings |
89
|
|
|
*/ |
90
|
26 |
|
protected function defaultSettings(): Settings |
91
|
|
|
{ |
92
|
|
|
return |
93
|
26 |
|
(new Settings()) |
94
|
26 |
|
->setInterval(static::INTERVAL) |
95
|
26 |
|
->setFrames(static::FRAMES) |
96
|
26 |
|
->setStyles(static::STYLES); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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