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

CorrelationIdProvider::incrementIdentifier()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
nc 1
nop 0
crap 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