Test Failed
Pull Request — master (#3)
by
unknown
18:49
created

CorrelationIdProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 25
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A incrementIdentifier() 0 4 1
A __construct() 0 5 1
A getCorrelationId() 0 8 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Paysera\LoggingExtraBundle\Service;
6
7
class CorrelationIdProvider
8
{
9
    private $correlationId;
10
    private $increment;
11
12
    public function __construct(string $systemName)
13
    {
14
        $this->correlationId = uniqid($systemName, true);
15
        $this->increment = 0;
16
    }
17
18
    public function getCorrelationId(): string
19
    {
20
        if ($this->increment === 0) {
21
            return $this->correlationId;
22
        }
23
24
        return sprintf('%s_%s', $this->correlationId, $this->increment);
25
    }
26
27
    public function incrementIdentifier()
28
    {
29
        $this->increment++;
30
    }
31
}
32