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

Sequence   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
wmc 2
lcom 1
cbo 0
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMessageId() 0 6 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