WebExtendedProcessor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 46
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 13 2
1
<?php
2
3
namespace Norsys\LogsBundle\Processor;
4
5
/**
6
 * Class WebExtendedProcessor
7
 */
8
class WebExtendedProcessor
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $serverData;
14
15
    /**
16
     * @var array
17
     */
18
    protected $postData;
19
20
    /**
21
     * @var array
22
     */
23
    protected $getData;
24
25
    /**
26
     * @param array $serverData
27
     * @param array $postData
28
     * @param array $getData
29
     */
30
    public function __construct(array $serverData = null, array $postData = null, array $getData = null)
31
    {
32 1
        $this->serverData = $serverData ?? $_SERVER;
33 1
        $this->postData   = $postData ?? $_POST;
34 1
        $this->getData    = $getData ?? $_GET;
35 1
    }
36
37
    /**
38
     * @param  array $record
39
     * @return array
40
     */
41
    public function __invoke(array $record)
42
    {
43
        // Skip processing if for some reason request data
44
        // Is not present (CLI or wonky SAPIs)
45 1
        if (isset($this->serverData['REQUEST_URI']) === false) {
46 1
            return $record;
47
        }
48
49 1
        $record['http_server'] = $this->serverData;
50 1
        $record['http_post']   = $this->postData;
51 1
        $record['http_get']    = $this->getData;
52
53 1
        return $record;
54
    }
55
}
56