Completed
Push — develop ( e125f2...8852f9 )
by
unknown
09:03
created

RequestIdProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A processRecord() 0 10 2
1
<?php
2
/**
3
 * monolog processor that adds a requestid to the record
4
 */
5
6
namespace Graviton\LogBundle\Monolog\Processor;
7
8
/**
9
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
10
 * @license  https://opensource.org/licenses/MIT MIT License
11
 * @link     http://swisscom.ch
12
 */
13
class RequestIdProcessor
14
{
15
16
    /**
17
     * @var string
18
     */
19
    private $requestId;
20
21
    /**
22
     * processes the record and adds a random request id
23
     *
24
     * @param array $record record
25
     *
26
     * @return array new record
27
     */
28 2
    public function processRecord(array $record)
29
    {
30 2
        if (is_null($this->requestId)) {
31 2
            $this->requestId = uniqid('', true);
32
        }
33
34 2
        $record['extra']['requestId'] = $this->requestId;
35
36 2
        return $record;
37
    }
38
}
39