Completed
Push — master ( c4a49a...0cfcd8 )
by Márk
03:21
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\Context;
4
5
use Nofw\Error\Context;
6
7
/**
8
 * Collects the session from the PHP $_SESSION global if available.
9
 *
10
 * @author Márk Sági-Kazár <[email protected]>
11
 */
12
final class PhpSessionCollector implements Processor
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public function process(\Throwable $t, array $context): array
18
    {
19
        if (!empty($_SESSION)) {
20
            return array_replace_recursive(
21
                [
22
                    Context::SESSION => $_SESSION,
23
                ],
24
                $context
25
            );
26
        }
27
28
        return $context;
29
    }
30
}
31