Test Failed
Push — master ( 131fc3...3e7ec2 )
by Serhii
18:02 queued 12:24
created

ProgressBarFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 29
ccs 0
cts 14
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 14 1
1
<?php
2
3
namespace Matchish\ScoutElasticSearch\Console\Commands;
4
5
use Symfony\Component\Console\Helper\ProgressBar;
6
use Symfony\Component\Console\Style\OutputStyle;
7
8
class ProgressBarFactory
9
{
10
    /**
11
     * @var OutputStyle
12
     */
13
    private $output;
14
15
    /**
16
     * @param OutputStyle $output
17
     */
18
    public function __construct(OutputStyle $output)
19
    {
20
        $this->output = $output;
21
    }
22
23
    public function create(int $max = 0): ProgressBar
24
    {
25
        $bar = $this->output->createProgressBar($max);
26
        $bar->setBarCharacter('<fg=green>⚬</>');
27
        $bar->setEmptyBarCharacter('<fg=red>⚬</>');
28
        $bar->setProgressCharacter('<fg=green>➤</>');
29
        $bar->setRedrawFrequency(1);
30
        $bar->maxSecondsBetweenRedraws(0);
31
        $bar->minSecondsBetweenRedraws(0);
32
        $bar->setFormat(
33
            "%message%\n%current%/%max% [%bar%] %percent:3s%%\n"
34
        );
35
36
        return $bar;
37
    }
38
}
39