Completed
Pull Request — master (#3)
by Romain
01:47
created

Delivery::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 3
1
<?php
2
namespace Kerox\Messenger\Model\Callback;
3
4
class Delivery
5
{
6
7
    /**
8
     * @var int
9
     */
10
    protected $watermark;
11
12
    /**
13
     * @var int
14
     */
15
    protected $sequence;
16
17
    /**
18
     * @var array
19
     */
20
    protected $messageIds;
21
22
    /**
23
     * Delivery constructor.
24
     *
25
     * @param array $messageIds
26
     * @param int $watermark
27
     * @param int $sequence
28
     */
29
    public function __construct(int $watermark, int $sequence, array $messageIds = [])
30
    {
31
        $this->watermark = $watermark;
32
        $this->sequence = $sequence;
33
        $this->messageIds = $messageIds;
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function getWatermark(): int
40
    {
41
        return $this->watermark;
42
    }
43
44
    /**
45
     * @return int
46
     */
47
    public function getSequence(): int
48
    {
49
        return $this->sequence;
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function getMessageIds(): array
56
    {
57
        return $this->messageIds;
58
    }
59
60
    /**
61
     * @param array $payload
62
     * @return static
63
     */
64
    public static function create(array $payload)
65
    {
66
        $messageIds = $payload['mids'] ?? [];
67
68
        return new static($payload['watermark'], $payload['seq'], $messageIds);
69
    }
70
}
71