DispatchCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\MessageSchedulerBundle\Command;
6
7
use Psr\Log\LoggerAwareInterface;
8
use Setono\MessageSchedulerBundle\Dispatcher\DispatcherInterface;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Logger\ConsoleLogger;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
final class DispatchCommand extends Command
15
{
16
    protected static $defaultName = 'setono:message-scheduler:dispatch';
17
18
    private DispatcherInterface $dispatcher;
19
20 1
    public function __construct(DispatcherInterface $dispatcher)
21
    {
22 1
        parent::__construct();
23
24 1
        $this->dispatcher = $dispatcher;
25 1
    }
26
27 1
    protected function configure(): void
28
    {
29 1
        $this->setDescription('Will dispatch messages, that are eligible for dispatching');
30 1
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        if ($this->dispatcher instanceof LoggerAwareInterface) {
35
            $this->dispatcher->setLogger(new ConsoleLogger($output));
0 ignored issues
show
Bug introduced by
The method setLogger() does not exist on Setono\MessageSchedulerB...her\DispatcherInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Setono\MessageSchedulerB...her\DispatcherInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
            $this->dispatcher->/** @scrutinizer ignore-call */ 
36
                               setLogger(new ConsoleLogger($output));
Loading history...
36
        }
37
38
        $this->dispatcher->dispatch();
39
40
        return 0;
41
    }
42
}
43