Completed
Pull Request — master (#51)
by Romain
02:30 queued 18s
created

RawEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 69.23%

Importance

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

4 Methods

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