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

ExceptionProcessor::__invoke()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 10
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
}