ListHandlerCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A execute() 0 11 3
A getMetadata() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Sonata Project package.
7
 *
8
 * (c) Thomas Rabaix <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Sonata\NotificationBundle\Command;
15
16
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
class ListHandlerCommand extends ContainerAwareCommand
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...d\ContainerAwareCommand has been deprecated with message: since Symfony 4.2, use {@see Command} instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function configure(): void
26
    {
27
        $this->setName('sonata:notification:list-handler');
28
        $this->setDescription('List all consumers available');
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function execute(InputInterface $input, OutputInterface $output): void
35
    {
36
        $output->writeln('<info>List of consumers available</info>');
37
        foreach ($this->getMetadata() as $type => $ids) {
38
            foreach ($ids as $id) {
39
                $output->writeln(sprintf('<info>%s</info> - <comment>%s</comment>', $type, $id));
40
            }
41
        }
42
43
        $output->writeln(' done!');
44
    }
45
46
    /**
47
     * @return array
48
     */
49
    private function getMetadata()
50
    {
51
        return $this->getContainer()->get('sonata.notification.consumer.metadata')->getInformations();
52
    }
53
}
54