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

Delivery   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 67
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getWatermark() 0 4 1
A getSequence() 0 4 1
A getMessageIds() 0 4 1
A create() 0 6 1
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