RawEvent   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
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 41
ccs 13
cts 13
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
3
declare(strict_types=1);
4
5
namespace Kerox\Messenger\Event;
6
7
class RawEvent extends AbstractEvent
8
{
9
    public const NAME = 'raw';
10
11
    /**
12
     * @var array
13
     */
14
    protected $raw;
15
16
    /**
17
     * RawEvent constructor.
18
     */
19 2
    public function __construct(string $senderId, string $recipientId, array $raw)
20
    {
21 2
        parent::__construct($senderId, $recipientId);
22
23 2
        $this->raw = $raw;
24 2
    }
25
26 1
    public function getRaw(): array
27
    {
28 1
        return $this->raw;
29
    }
30
31 1
    public function getName(): string
32
    {
33 1
        return self::NAME;
34
    }
35
36
    /**
37
     * @return \Kerox\Messenger\Event\RawEvent
38
     */
39 1
    public static function create(array $payload): self
40
    {
41 1
        $senderId = $payload['sender']['id'];
42 1
        $recipientId = $payload['recipient']['id'];
43 1
        unset($payload['sender'], $payload['recipient']);
44
45 1
        return new static($senderId, $recipientId, $payload);
46
    }
47
}
48