ProgressBar   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 55
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 7 1
A setMax() 0 4 1
A start() 0 10 2
A finish() 0 4 1
A advance() 0 4 1
1
<?php
2
3
namespace whm\Smoke\Extensions\SmokeProgressBar;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
class ProgressBar
8
{
9
    private $progressBar;
10
11
    private $width;
12
    private $format;
13
14
    private $max = 0;
15
    private $output;
16
17
    private $isStarted = false;
18
19
    public function init(OutputInterface $_output, $width = 100, $format = 'normal', $max = 0)
20
    {
21
        $this->width = $width;
22
        $this->format = $format;
23
        $this->max = $max;
24
        $this->output = $_output;
25
    }
26
27
    public function setMax($max)
28
    {
29
        $this->max = $max;
30
    }
31
32
    /**
33
     * @Event("Scanner.Scan.Begin")
34
     */
35
    public function start()
36
    {
37
        if (!$this->isStarted) {
38
            $this->isStarted = true;
39
            $this->progressBar = new \Symfony\Component\Console\Helper\ProgressBar($this->output, $this->max);
40
            $this->progressBar->setFormat($this->format);
41
            $this->progressBar->setBarWidth($this->width);
42
        }
43
        $this->progressBar->start();
44
    }
45
46
    /**
47
     * @Event("Scanner.Scan.Finish")
48
     */
49
    public function finish()
50
    {
51
        $this->progressBar->finish();
52
    }
53
54
    /**
55
     * @Event("Scanner.Scan.Validate")
56
     */
57
    public function advance()
58
    {
59
        $this->progressBar->advance();
60
    }
61
}
62