Passed
Push — main ( ed1bb6...4383ba )
by Slawomir
04:39
created

CommentCreatedPostsIEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 41
ccs 10
cts 10
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A getPostId() 0 3 1
A getComments() 0 3 1
A __construct() 0 5 1
1
<?php
2
3
namespace App\Modules\Posts\Api\Event\Inbound;
4
5
use App\Infrastructure\Events\ApplicationInboundEvent;
6
use Symfony\Component\Uid\Ulid;
7
8
class CommentCreatedPostsIEvent extends ApplicationInboundEvent
9
{
10
    const EVENT_NAME = "COMMENT_CREATED";
11
12
    private Ulid $postId;
13
14
    private array $comments;
15
16
    /**
17
     * @param array $data
18
     */
19
    public function __construct(array $data)
20 3
    {
21
        parent::__construct( $data);
22 3
        $this->postId = $this->ulid('postId');
23 3
        $this->comments = [$this->array('comment')];
24 3
    }
25 3
26
27
    /**
28
     * @return Ulid|null
29
     */
30
    public function getPostId(): ?Ulid
31 2
    {
32
        return $this->postId;
33 2
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getComments(): array
39 2
    {
40
        return $this->comments;
41 2
    }
42
43
    /**
44 1
     * @return string
45
     */
46
    public static function getName(): string
47
    {
48
        return self::EVENT_NAME;
49
    }
50
51
}