ReplyEvent::getEventName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Aent\Event;
4
5
use TheAentMachine\Helper\ReplyAggregator;
6
7
final class ReplyEvent extends AbstractEvent
8
{
9
    /** @var ReplyAggregator */
10
    private $replyAggregator;
11
12
    /**
13
     * ReplyEvent constructor.
14
     * @param ReplyAggregator $replyAggregator
15
     */
16
    public function __construct(ReplyAggregator $replyAggregator)
17
    {
18
        parent::__construct();
19
        $this->replyAggregator = $replyAggregator;
20
    }
21
22
    /**
23
     * @return void
24
     */
25
    protected function configure(): void
26
    {
27
        parent::configure();
28
        $this->setHidden(true);
29
    }
30
31
    /**
32
     * @return string
33
     */
34
    protected function getEventName(): string
35
    {
36
        return 'REPLY';
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    protected function shouldRegisterEvents(): bool
43
    {
44
        return false;
45
    }
46
47
    /**
48
     * @return void
49
     */
50
    protected function beforeExecute(): void
51
    {
52
        // Let's do nothing.
53
    }
54
55
    /**
56
     * @param null|string $payload
57
     * @return null|string
58
     */
59
    protected function executeEvent(?string $payload): ?string
60
    {
61
        $this->replyAggregator->storeReply($payload ?? '');
62
        return null;
63
    }
64
65
    /**
66
     * @return void
67
     */
68
    protected function afterExecute(): void
69
    {
70
        // Let's do nothing.
71
    }
72
}
73