DeliveryEvent::getDelivery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
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\Delivery;
8
9
class DeliveryEvent extends AbstractEvent
10
{
11
    public const NAME = 'delivery';
12
13
    /**
14
     * @var \Kerox\Messenger\Model\Callback\Delivery
15
     */
16
    protected $delivery;
17
18
    /**
19
     * DeliveryEvent constructor.
20
     */
21 2
    public function __construct(string $senderId, string $recipientId, Delivery $delivery)
22
    {
23 2
        parent::__construct($senderId, $recipientId);
24
25 2
        $this->delivery = $delivery;
26 2
    }
27
28 2
    public function getDelivery(): Delivery
29
    {
30 2
        return $this->delivery;
31
    }
32
33 1
    public function getName(): string
34
    {
35 1
        return self::NAME;
36
    }
37
38
    /**
39
     * @return \Kerox\Messenger\Event\DeliveryEvent
40
     */
41 1
    public static function create(array $payload): self
42
    {
43 1
        $senderId = $payload['sender']['id'];
44 1
        $recipientId = $payload['recipient']['id'];
45 1
        $delivery = Delivery::create($payload['delivery']);
46
47 1
        return new static($senderId, $recipientId, $delivery);
48
    }
49
}
50