PingCommand::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Happyr\SimpleBusBundle\Command;
4
5
use Happyr\SimpleBusBundle\Message\Command\Ping;
6
use Happyr\SimpleBusBundle\Message\Event\Pong;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
10
11
/**
12
 * Test if SimpleBus works.
13
 *
14
 * @author Tobias Nyholm <[email protected]>
15
 */
16
class PingCommand extends ContainerAwareCommand
17
{
18
    protected function configure()
19
    {
20
        $this
21
            ->setName('happyr:simplebus:ping')
22
            ->setDescription('Ping test');
23
    }
24
25
    protected function execute(InputInterface $input, OutputInterface $output)
26
    {
27
        $this->get('command_bus')->handle(new Ping('4711'));
28
        $this->get('event_bus')->handle(new Pong('4711-pong'));
29
    }
30
31
    /**
32
     * @param string $service
33
     *
34
     * @return object
35
     */
36
    private function get(string $service)
37
    {
38
        return $this->getContainer()->get($service);
39
    }
40
}
41