Passed
Push — master ( 095b07...d08e35 )
by Alec
02:42
created

PercentSpinner::defaultSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace AlecRabbit\Spinner;
4
5
use AlecRabbit\Spinner\Core\Contracts\StylesInterface;
6
use AlecRabbit\Spinner\Core\Spinner;
7
use AlecRabbit\Spinner\Settings\Contracts\Defaults;
8
use AlecRabbit\Spinner\Settings\Settings;
9
use function AlecRabbit\typeOf;
10
11
class PercentSpinner extends Spinner
12
{
13
    protected const INTERVAL = 0.1;
14
    protected const FRAMES = [];
15
    protected const
16
        STYLES =
17
        [
18
            StylesInterface::SPINNER_STYLES =>
19
                [
20
                    StylesInterface::COLOR256 => StylesInterface::DISABLED,
21
                    StylesInterface::COLOR => StylesInterface::DISABLED,
22
                ],
23
        ];
24
25
    /** {@inheritDoc} */
26 2
    public function spin(?float $percent = null): string
27
    {
28 2
        $percent and $this->progress($percent);
29 2
        return parent::spin();
30
    }
31
32
    /** {@inheritDoc} */
33 2
    public function begin(?float $percent = null): string
34
    {
35 2
        return parent::begin(0.0);
36
    }
37
38
    /** {@inheritDoc} */
39 1
    public function message(?string $message = null, ?int $erasingLength = null): Spinner
40
    {
41 1
        return $this;
42
    }
43
44
//    /** {@inheritDoc} */
45
//    public function progress(?float $percent): Spinner
46
//    {
47
//        return $this;
48
//    }
49
50
    /** {@inheritDoc} */
51 2
    protected function defaultSettings(): Settings
52
    {
53
        return
54 2
            parent::defaultSettings()
55 2
                ->setMessagePrefix(Defaults::EMPTY_STRING);
56
    }
57
}
58