ProgressBarFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 12
    public function __construct(OutputStyle $output)
19
    {
20 12
        $this->output = $output;
21 12
    }
22
23 12
    public function create(int $max = 0): ProgressBar
24
    {
25 12
        $bar = $this->output->createProgressBar($max);
26 12
        $bar->setBarCharacter('<fg=green>⚬</>');
27 12
        $bar->setEmptyBarCharacter('<fg=red>⚬</>');
28 12
        $bar->setProgressCharacter('<fg=green>➤</>');
29 12
        $bar->setRedrawFrequency(1);
30 12
        $bar->maxSecondsBetweenRedraws(0);
31 12
        $bar->minSecondsBetweenRedraws(0);
32 12
        $bar->setFormat(
33 12
            "%message%\n%current%/%max% [%bar%] %percent:3s%%\n"
34
        );
35
36 12
        return $bar;
37
    }
38
}
39