Completed
Pull Request — master (#13)
by Rafael
06:46
created

SubscriptionConsumerCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 48
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 3 1
A configure() 0 4 1
A __construct() 0 7 1
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Command;
12
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Output\OutputInterface;
16
use Symfony\Component\HttpKernel\Kernel;
17
use Symfony\Component\HttpKernel\KernelInterface;
18
use Symfony\Component\Mercure\Publisher;
19
use Ynlo\GraphQLBundle\Subscription\SubscriptionManager;
20
21
class SubscriptionConsumerCommand extends Command
22
{
23
    /**
24
     * @var SubscriptionManager
25
     */
26
    protected $subscriptionManager;
27
28
    /**
29
     * @var KernelInterface
30
     */
31
    protected $kernel;
32
33
    /**
34
     * @var Publisher
35
     */
36
    protected $publisher;
37
38
    /**
39
     * SubscriptionConsumerCommand constructor.
40
     *
41
     * @param Kernel              $kernel
42
     * @param SubscriptionManager $subscriptionManager
43
     * @param Publisher           $publisher
44
     */
45
    public function __construct(Kernel $kernel, SubscriptionManager $subscriptionManager, Publisher $publisher)
46
    {
47
        parent::__construct();
48
49
        $this->kernel = $kernel;
50
        $this->subscriptionManager = $subscriptionManager;
51
        $this->publisher = $publisher;
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57
    protected function configure()
58
    {
59
        $this->setName('graphql:subscriptions:consume')
60
             ->setDescription('Listen for subscriptions to consume then and dispatch to mercure HUB.');
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    protected function execute(InputInterface $input, OutputInterface $output)
67
    {
68
        $this->subscriptionManager->consume($output, $input->getOption('verbose'));
69
    }
70
}
71