Passed
Push — master ( afa595...3d30f2 )
by Marcel
08:58
created

ExceptionProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 3
1
<?php
2
3
namespace App\Monolog;
4
5
use Monolog\Processor\ProcessorInterface;
6
use Throwable;
7
8
class ExceptionProcessor implements ProcessorInterface {
9
10
    public function __invoke(array $records): array {
11
        if(isset($records['context']['exception']) && $records['context']['exception'] instanceof Throwable) {
12
            $records['extra']['exception'] = [
13
                'class' => $records['context']['exception']::class,
14
                'message' => $records['context']['exception']->getMessage(),
15
                'stacktrace' => $records['context']['exception']->getTraceAsString()
16
            ];
17
        }
18
19
        return $records;
20
    }
21
}