Conditions | 6 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 9.5384 |
Changes | 0 |
1 | <?php |
||
15 | 9 | public function setupOnce(): void |
|
16 | { |
||
17 | 1 | Scope::addGlobalEventProcessor(static function (Event $event, ?EventHint $hint = null): Event { |
|
18 | 9 | $self = SentrySdk::getCurrentHub()->getIntegration(self::class); |
|
19 | |||
20 | 9 | if (!$self instanceof self) { |
|
21 | 8 | return $event; |
|
22 | } |
||
23 | |||
24 | 1 | if ($hint === null || $hint->exception === null) { |
|
25 | 1 | return $event; |
|
26 | } |
||
27 | |||
28 | if (!method_exists($hint->exception, 'context')) { |
||
29 | return $event; |
||
30 | } |
||
31 | |||
32 | /** @psalm-suppress MixedAssignment $context */ |
||
33 | $context = $hint->exception->context(); |
||
34 | |||
35 | if (is_array($context)) { |
||
36 | $event->setExtra(['exception_context' => $context]); |
||
37 | } |
||
38 | |||
39 | return $event; |
||
40 | }); |
||
43 |