Completed
Push — master ( c0b61c...1b53d6 )
by GBProd
02:17
created

ProvidingProgressBar   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 44.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 46
ccs 12
cts 27
cp 0.4444
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 34 1
1
<?php
2
3
namespace GBProd\ElasticsearchDataProviderBundle\Command;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
7
use GBProd\ElasticsearchDataProviderBundle\Event\HasStartedHandling;
8
use GBProd\ElasticsearchDataProviderBundle\Event\HasStartedProviding;
9
use GBProd\ElasticsearchDataProviderBundle\Event\HasIndexingDocument;
10
11
/**
12
 * Progress bar for providing
13
 * 
14
 * @author gbprod <[email protected]>
15
 */
16
class ProvidingProgressBar
17
{
18
    /**
19
     * @var OutputInterface
20
     */
21
    private $output;
0 ignored issues
show
Unused Code introduced by
The property $output is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
22
    
23
    /**
24
     * @param EventDispatcherInterface $dispatcher
25
     * @param OutputInterface          $output
26
     */
27 1
    public function __construct(
28
        EventDispatcherInterface $dispatcher, 
29
        OutputInterface $output
30
    ) {
31 1
        $dispatcher->addListener(
32 1
            'elasticsearch.has_started_handling',
33
            function (HasStartedHandling $event) use ($output) {
34
                $output->writeln(sprintf(
35
                    '<info>Start running <comment>%d</comment> providers</info>', 
36
                    count($event->getEntries())
37
                ));
38
            }
39 1
        );
40
41 1
        $dispatcher->addListener(
42 1
            'elasticsearch.has_started_providing',
43
            function (HasStartedProviding $event) use ($output) {
44
                $output->writeln(sprintf(
45
                    '<info>Start running <comment>%s</comment> provider</info>',
46
                    get_class($event->getEntry()->getProvider())
47 1
                ));
48
            }
49 1
        );
50
        
51 1
        $dispatcher->addListener(
52 1
            'elasticsearch.has_indexed_document',
53
            function (HasIndexingDocument $event) use ($output) {
54
                $output->writeln(sprintf(
55
                    '<info>Indexing <comment>%s</comment> document</info>',
56
                    get_class($event->getEntry()->getId())
57
                ));
58
            }
59 1
        );
60
    }
61
}