1 | <?php |
||
18 | class ProvidingProgressBar |
||
19 | { |
||
20 | const PROGRESS_BAR_TEMPLATE = ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'; |
||
21 | |||
22 | /** |
||
23 | * @var OutputInterface |
||
24 | */ |
||
25 | private $output; |
||
26 | |||
27 | /** |
||
28 | * @var EventDispatcherInterface |
||
29 | */ |
||
30 | private $dispatcher; |
||
31 | |||
32 | /** |
||
33 | * @var ProgressBar |
||
34 | * |
||
35 | * public for test purpose |
||
36 | */ |
||
37 | public $progressBar; |
||
38 | |||
39 | /** |
||
40 | * @param EventDispatcherInterface $dispatcher |
||
41 | * @param OutputInterface $output |
||
42 | */ |
||
43 | 8 | public function __construct( |
|
44 | EventDispatcherInterface $dispatcher, |
||
45 | OutputInterface $output |
||
46 | ) { |
||
47 | 8 | $this->output = $output; |
|
48 | 8 | $this->dispatcher = $dispatcher; |
|
49 | |||
50 | 8 | $this->listen('elasticsearch.has_started_handling', 'onStartedHandling'); |
|
51 | 8 | $this->listen('elasticsearch.has_started_providing', 'onStartedProviding'); |
|
52 | 8 | $this->listen('elasticsearch.has_provided_document', 'onProvidedDocument'); |
|
53 | 8 | $this->listen('elasticsearch.has_finished_providing', 'onFinishedProviding'); |
|
54 | 8 | } |
|
55 | |||
56 | 8 | private function listen($eventName, $function) |
|
60 | |||
61 | 1 | public function onStartedHandling(HasStartedHandling $event) |
|
62 | { |
||
63 | 1 | $this->output->writeln( |
|
64 | 1 | sprintf( |
|
65 | 1 | '<info>Start running <comment>%d</comment> providers</info>', |
|
66 | 1 | count($event->getEntries()) |
|
67 | 1 | ) |
|
68 | 1 | ); |
|
69 | 1 | } |
|
70 | |||
71 | 4 | public function onStartedProviding(HasStartedProviding $event) |
|
86 | |||
87 | 1 | public function onProvidedDocument(HasProvidedDocument $event) |
|
93 | |||
94 | 1 | public function onFinishedProviding(HasFinishedProviding $event) |
|
103 | } |
||
104 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.