Passed
Push — master ( 13396d...079212 )
by Alec
08:54
created

Style::percent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 4
cts 4
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\Core;
4
5
use AlecRabbit\Accessories\Circular;
6
7
/**
8
 * Class Styling
9
 *
10
 * @internal
11
 */
12
class Style
13
{
14
    /** @var Circular */
15
    protected $symbolStyles;
16
    /** @var Circular */
17
    protected $messageStyles;
18
    /** @var Circular */
19
    protected $percentStyles;
20
21
    /**
22
     * Styles constructor.
23
     * @param array $styles
24
     * @param mixed $color
25
     */
26 11
    public function __construct(array $styles, $color = null)
27
    {
28 11
        $prototype = new Prototype($styles, $color);
29 11
        $this->symbolStyles = $prototype->getSpinnerStyles();
30 11
        $this->messageStyles = $prototype->getMessageStyles();
31 11
        $this->percentStyles = $prototype->getPercentStyles();
32 11
    }
33
34 10
    public function spinner(string $symbol): string
35
    {
36 10
        return sprintf((string)$this->symbolStyles->value(), $symbol);
37
    }
38
39 10
    public function message(string $message): string
40
    {
41
        return
42 10
            sprintf(
43 10
                (string)$this->messageStyles->value(),
44 10
                $message
45
            );
46
    }
47
48 10
    public function percent(string $percent): string
49
    {
50
        return
51 10
            sprintf(
52 10
                (string)$this->percentStyles->value(),
53 10
                $percent
54
            );
55
    }
56
}
57