Passed
Pull Request — master (#15)
by Serhii
06:06
created

ProgressBarFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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