Completed
Push — master ( f8d4b2...9b5d9d )
by Márk
10s
created

PhpSessionCollector   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 2
1
<?php
2
3
namespace Nofw\Emperror\Processor;
4
5
use Nofw\Emperror\Processor;
6
use Nofw\Error\Context;
7
8
/**
9
 * Collects the session from the PHP $_SESSION global if available.
10
 *
11
 * @author Márk Sági-Kazár <[email protected]>
12
 */
13
final class PhpSessionCollector implements Processor
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function process(\Throwable $t, array $context): array
19
    {
20
        if (!empty($_SESSION)) {
21
            return array_replace_recursive(
22
                [
23
                    Context::SESSION => $_SESSION,
24
                ],
25
                $context
26
            );
27
        }
28
29
        return $context;
30
    }
31
}
32