forked from bmitch/churn-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBarSubscriber.php
More file actions
60 lines (52 loc) · 1.58 KB
/
ProgressBarSubscriber.php
File metadata and controls
60 lines (52 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Churn\Command\Helper;
use Churn\Event\Event\AfterAnalysis as AfterAnalysisEvent;
use Churn\Event\Event\AfterFileAnalysis as AfterFileAnalysisEvent;
use Churn\Event\Event\BeforeAnalysis as BeforeAnalysisEvent;
use Churn\Event\Subscriber\AfterAnalysis;
use Churn\Event\Subscriber\AfterFileAnalysis;
use Churn\Event\Subscriber\BeforeAnalysis;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @internal
*/
final class ProgressBarSubscriber implements AfterAnalysis, AfterFileAnalysis, BeforeAnalysis
{
/**
* @var ProgressBar
*/
private $progressBar;
/**
* @param OutputInterface $output The console output.
*/
public function __construct(OutputInterface $output)
{
$this->progressBar = new ProgressBar($output);
}
/**
* @param AfterAnalysisEvent $event The event triggered when the analysis is done.
*/
#[\Override]
public function onAfterAnalysis(AfterAnalysisEvent $event): void
{
$this->progressBar->finish();
}
/**
* @param BeforeAnalysisEvent $event The event triggered when the analysis starts.
*/
#[\Override]
public function onBeforeAnalysis(BeforeAnalysisEvent $event): void
{
$this->progressBar->start();
}
/**
* @param AfterFileAnalysisEvent $event The event triggered when the analysis of a file is done.
*/
#[\Override]
public function onAfterFileAnalysis(AfterFileAnalysisEvent $event): void
{
$this->progressBar->advance();
}
}