ProgressBarFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 29
ccs 14
cts 14
cp 1
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 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