BasePublisherCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 10
c 3
b 0
f 0
dl 0
loc 50
ccs 10
cts 10
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPublisher() 0 3 1
A __construct() 0 4 1
A handle() 0 5 1
1
<?php
2
namespace NeedleProject\LaravelRabbitMq\Command;
3
4
use Illuminate\Console\Command;
5
use Monolog\Handler\StreamHandler;
6
use Monolog\Logger;
7
use NeedleProject\LaravelRabbitMq\ConsumerInterface;
8
use NeedleProject\LaravelRabbitMq\Container;
9
use NeedleProject\LaravelRabbitMq\PublisherInterface;
10
use Psr\Log\LoggerAwareInterface;
11
use Psr\Log\LoggerInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
/**
15
 * Class BasePublisherCommand
16
 *
17
 * @package NeedleProject\LaravelRabbitMq\Command
18
 * @author  Adrian Tilita <[email protected]>
19
 */
20
class BasePublisherCommand extends Command
21
{
22
    /**
23
     * The name and signature of the console command.
24
     *
25
     * @var string
26
     */
27
    protected $signature = 'rabbitmq:publish {publisher} {message}';
28
29
    /**
30
     * The console command description.
31
     *
32
     * @var string
33
     */
34
    protected $description = 'Publish one message';
35
36
    /**
37
     * @var null|Container
38
     */
39
    private $container = null;
40
41
    /**
42
     * BasePublisherCommand constructor.
43
     *
44
     * @param Container $container
45
     */
46 1
    public function __construct(Container $container)
47
    {
48 1
        $this->container = $container;
49 1
        parent::__construct();
50 1
    }
51
52
    /**
53
     * @param string $publisherAliasName
54
     * @return PublisherInterface
55
     */
56 1
    protected function getPublisher(string $publisherAliasName): PublisherInterface
57
    {
58 1
        return $this->container->getPublisher($publisherAliasName);
0 ignored issues
show
Bug introduced by
The method getPublisher() does not exist on null. ( Ignorable by Annotation )

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

58
        return $this->container->/** @scrutinizer ignore-call */ getPublisher($publisherAliasName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
    }
60
61
    /**
62
     * Execute the console command.
63
     * @return int
64
     */
65 1
    public function handle()
66
    {
67 1
        $this->getPublisher($this->input->getArgument('publisher'))
68 1
            ->publish($this->input->getArgument('message'));
69 1
        return 0;
70
    }
71
}
72