Completed
Pull Request — master (#139)
by Romain
03:43
created

Delivery::getSequence()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
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\Model\Callback;
6
7
class Delivery
8
{
9
    /**
10
     * @var int
11
     */
12
    protected $watermark;
13
14
    /**
15
     * @var array
16
     */
17
    protected $messageIds;
18
19
    /**
20
     * Delivery constructor.
21
     *
22
     * @param array $messageIds
23
     * @param int   $watermark
24
     */
25
    public function __construct(int $watermark, array $messageIds = [])
26
    {
27
        $this->watermark = $watermark;
28
        $this->messageIds = $messageIds;
29
    }
30
31 2
    /**
32
     * @return int
33 2
     */
34 2
    public function getWatermark(): int
35 2
    {
36 2
        return $this->watermark;
37
    }
38
39
    /**
40
     * @return array
41 1
     */
42
    public function getMessageIds(): array
43 1
    {
44
        return $this->messageIds;
45
    }
46
47
    /**
48
     * @param array $callbackData
49 1
     *
50
     * @return \Kerox\Messenger\Model\Callback\Delivery
51 1
     */
52
    public static function create(array $callbackData): self
53
    {
54
        $messageIds = $callbackData['mids'] ?? [];
55
56
        return new self($callbackData['watermark'], $messageIds);
57 1
    }
58
}
59