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

ProgressBarFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

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