Passed
Push — master ( 8a7749...5c0d1f )
by Romain
39s queued 10s
created

RequestThreadControlEvent::getTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Event;
6
7
use Kerox\Messenger\Model\Callback\RequestThreadControl;
8
9
class RequestThreadControlEvent extends AbstractEvent
10
{
11
    public const NAME = 'request_thread_control';
12
13
    /**
14
     * @var int
15
     */
16
    protected $timestamp;
17
18
    /**
19
     * @var \Kerox\Messenger\Model\Callback\RequestThreadControl
20
     */
21
    protected $requestThreadControl;
22
23
    /**
24
     * TakeThreadControlEvent constructor.
25
     *
26
     * @param string                                               $senderId
27
     * @param string                                               $recipientId
28
     * @param int                                                  $timestamp
29
     * @param \Kerox\Messenger\Model\Callback\RequestThreadControl $requestThreadControl
30
     */
31 2
    public function __construct(
32
        string $senderId,
33
        string $recipientId,
34
        int $timestamp,
35
        RequestThreadControl $requestThreadControl
36
    ) {
37 2
        parent::__construct($senderId, $recipientId);
38
39 2
        $this->timestamp = $timestamp;
40 2
        $this->requestThreadControl = $requestThreadControl;
41 2
    }
42
43
    /**
44
     * @return int
45
     */
46 1
    public function getTimestamp(): int
47
    {
48 1
        return $this->timestamp;
49
    }
50
51
    /**
52
     * @return \Kerox\Messenger\Model\Callback\RequestThreadControl
53
     */
54 1
    public function getRequestThreadControl(): RequestThreadControl
55
    {
56 1
        return $this->requestThreadControl;
57
    }
58
59
    /**
60
     * @return string
61
     */
62 1
    public function getName(): string
63
    {
64 1
        return self::NAME;
65
    }
66
67
    /**
68
     * @param array $payload
69
     *
70
     * @return \Kerox\Messenger\Event\RequestThreadControlEvent
71
     */
72 1
    public static function create(array $payload): self
73
    {
74 1
        $senderId = $payload['sender']['id'];
75 1
        $recipientId = $payload['recipient']['id'];
76 1
        $timestamp = $payload['timestamp'];
77 1
        $requestThreadControl = RequestThreadControl::create($payload['request_thread_control']);
78
79 1
        return new static($senderId, $recipientId, $timestamp, $requestThreadControl);
80
    }
81
}
82