Passed
Push — master ( 055b76...bacc0b )
by Patrick
01:33 queued 12s
created

QueueClientConsumerConsoleCommandPlugin::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\QueueClient\Shared\Plugin;
13
14
use ForecastAutomation\Kernel\Shared\Plugin\AbstractCommandPlugin;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * @method \ForecastAutomation\QueueClient\QueueClientFacade getFacade()
21
 */
22
class QueueClientConsumerConsoleCommandPlugin extends AbstractCommandPlugin
23
{
24
    public const COMMAND_NAME = 'queue:client:consumer';
25
    public const DESCRIPTION = 'This command will consume messages in topics and call related processors.';
26
    public const ARGUMENT_QUEUE_NAME = 'queue_name';
27
28
    protected function configure(): void
29
    {
30
        $this->setName(self::COMMAND_NAME);
31
        $this->setDescription(self::DESCRIPTION);
32
        $this->addArgument(self::ARGUMENT_QUEUE_NAME, InputArgument::REQUIRED, 'Please add one of your registered Queue Plugins (QueuePluginCollection) as an argument.');
33
34
        parent::configure();
35
    }
36
37
    protected function execute(InputInterface $input, OutputInterface $output): int
38
    {
39
        $this->getFacade()->consume($input->getArgument(self::ARGUMENT_QUEUE_NAME));
40
41
        return self::SUCCESS;
42
    }
43
}
44