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

Style   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 17
dl 0
loc 42
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A spinner() 0 3 1
A percent() 0 6 1
A __construct() 0 6 1
A message() 0 6 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