Completed
Push — master ( 6435a2...ebbf46 )
by Julien
01:57
created

PushMessageCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Eole\Sandstone\Tests\Integration\App;
4
5
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Command\Command;
9
use Eole\Sandstone\Tests\Integration\App\ArticleCreatedEvent;
10
11
class PushMessageCommand extends Command
12
{
13
    /**
14
     * @var EventDispatcherInterface
15
     */
16
    private $dispatcher;
17
18
    /**
19
     * @param EventDispatcherInterface $dispatcher
20
     */
21
    public function __construct(EventDispatcherInterface $dispatcher)
22
    {
23
        parent::__construct('sandstone:test:push');
24
25
        $this->dispatcher = $dispatcher;
26
    }
27
28
    /**
29
     * {@InheritDoc}
30
     */
31
    protected function configure()
32
    {
33
        parent::configure();
34
35
        $this
36
            ->setDescription('Dispatch an event which should push an event.')
37
        ;
38
    }
39
40
    /**
41
     * {@InheritDoc}
42
     */
43
    protected function execute(InputInterface $input, OutputInterface $output)
44
    {
45
        $id = 42;
46
        $title = 'Unicorns spotted in Alaska';
47
        $url = 'http://unicorn.com/articles/unicorns-spotted-alaska';
48
49
        $event = new ArticleCreatedEvent($id, $title, $url);
50
51
        $this->dispatcher->dispatch('article.created', $event);
52
    }
53
}
54