Passed
Push — master ( 079212...632fb9 )
by Alec
02:27
created

PercentSpinner::begin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Spinner;
4
5
use AlecRabbit\Spinner\Contracts\SettingsInterface;
6
use AlecRabbit\Spinner\Contracts\StylesInterface;
7
use AlecRabbit\Spinner\Core\Settings;
8
use AlecRabbit\Spinner\Core\Spinner;
9
use function AlecRabbit\typeOf;
10
11
class PercentSpinner extends Spinner
12
{
13
    protected const ERASING_SHIFT = 1;
14
    protected const INTERVAL = 0.1;
15
    protected const SYMBOLS = null;
16
    protected const
17
        STYLES =
18
        [
19
            StylesInterface::SPINNER_STYLES =>
20
                [
21
                    StylesInterface::COLOR256 => StylesInterface::DISABLED,
22
                    StylesInterface::COLOR => StylesInterface::DISABLED,
23
                ],
24
        ];
25
26
    /**
27
     * @return Settings
28
     */
29 3
    protected function defaultSettings(): Settings
30
    {
31
        return
32 3
            parent::defaultSettings()
33 3
                ->setPrefix(SettingsInterface::EMPTY);
34
    }
35
36 2
    public function spin(?float $percent = null): string
37
    {
38 2
        if (!\is_float($percent)) {
39 1
            throw new \RuntimeException('Float percentage value expected ' . typeOf($percent) . ' given.');
40
        }
41 1
        return parent::spin($percent);
42
    }
43
44 1
    public function begin(?float $percent = null): string
45
    {
46 1
        return parent::begin(0.0);
47
    }
48
}
49