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

Delivery   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 9
c 1
b 0
f 1
dl 0
loc 50
ccs 9
cts 9
cp 1
rs 10

4 Methods

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