PostService::createPost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Core\Console\Tests\Fixtures\Command;
12
13
use Cubiche\Core\EventBus\Event\EventBus;
14
use Cubiche\Core\Console\Tests\Fixtures\Event\PostTitleWasChanged;
15
use Cubiche\Core\Console\Tests\Fixtures\Event\PostWasCreated;
16
use Cubiche\Core\Console\Tests\Fixtures\Post;
17
18
/**
19
 * PostService class.
20
 *
21
 * @author Ivannis Suárez Jerez <[email protected]>
22
 */
23
class PostService
24
{
25
    /**
26
     * @var EventBus
27
     */
28
    protected $eventBus;
29
30
    /**
31
     * PostService constructor.
32
     *
33
     * @param EventBus $eventBus
34
     */
35
    public function __construct(EventBus $eventBus)
36
    {
37
        $this->eventBus = $eventBus;
38
    }
39
40
    /**
41
     * @param CreatePostCommand $command
42
     */
43
    public function createPost(CreatePostCommand $command)
44
    {
45
        $this->eventBus->dispatch(new PostWasCreated($command->title(), $command->content()));
46
    }
47
48
    /**
49
     * @param ChangePostTitleCommand $command
50
     */
51
    public function changePostTitle(ChangePostTitleCommand $command)
52
    {
53
        $this->eventBus->dispatch(new PostTitleWasChanged($command->title()));
54
    }
55
}
56