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

ProgressBarFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 14
ccs 0
cts 11
cp 0
crap 2
rs 9.9332
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