Completed
Push — master ( 61c7e0...bbf351 )
by Gaetano
07:00
created

Sequence::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Kaliop\Queueing\Plugins\SQSBundle\Service\MessageDeduplicationIdCalculator;
4
5
use Kaliop\Queueing\Plugins\SQSBundle\Adapter\SQS\MessageDeduplicationIdCalculatorInterface;
6
7
/**
8
 * An extremely simple 'unique message id' generator, geared for demonstration more than anything else...
9
 */
10
class Sequence implements MessageDeduplicationIdCalculatorInterface
11
{
12
    protected $current = 0;
13
    protected $increment = 1;
14
15 1
    public function __construct($start = 0, $increment = 1)
16
    {
17 1
        $this->current = $start;
18 1
        $this->increment = $increment;
19 1
    }
20
21 1
    public function getMessageId($msgBody, $routingKey = '', array $additionalProperties = array())
22
    {
23 1
        $value = getmypid() . '_' . $this->current;
24 1
        $this->current += $this->increment;
25 1
        return $value;
26
    }
27
}
28