PostService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createPost() 0 4 1
A changePostTitle() 0 4 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