Completed
Pull Request — master (#19)
by Romain
02:15
created

RawEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 53
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getRaw() 0 4 1
A getName() 0 4 1
A create() 0 8 1
1
<?php
2
namespace Kerox\Messenger\Event;
3
4
class RawEvent extends AbstractEvent
5
{
6
7
    const NAME = 'raw';
8
9
    /**
10
     * @var array
11
     */
12
    protected $raw;
13
14
    /**
15
     * RawEvent constructor.
16
     *
17
     * @param string $senderId
18
     * @param string $recipientId
19
     * @param array $raw
20
     */
21 1
    public function __construct(string $senderId, string $recipientId, array $raw)
22
    {
23 1
        parent::__construct($senderId, $recipientId);
24
25 1
        $this->raw = $raw;
26 1
    }
27
28
    /**
29
     * @return array
30
     */
31
    public function getRaw(): array
32
    {
33
        return $this->raw;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getName(): string
40
    {
41
        return self::NAME;
42
    }
43
44
    /**
45
     * @param array $payload
46
     * @return \Kerox\Messenger\Event\RawEvent
47
     */
48 1
    public static function create(array $payload): RawEvent
49
    {
50 1
        $senderId = $payload['sender']['id'];
51 1
        $recipientId = $payload['recipient']['id'];
52 1
        unset($payload['sender'], $payload['recipient']);
53
54 1
        return new static($senderId, $recipientId, $payload);
55
    }
56
}
57