ConsoleCommandFinishedListener   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 10
c 2
b 0
f 0
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Jaravel\Listeners;
6
7
use Illuminate\Console\Events\CommandFinished;
8
use Illuminate\Support\Facades\Config;
9
use OpenTelemetry\SDK\Trace\Span;
10
use Umbrellio\Jaravel\Services\Caller;
11
use Umbrellio\Jaravel\Services\Span\SpanTagHelper;
12
13
class ConsoleCommandFinishedListener
14
{
15
    public function handle(CommandFinished $event): void
16
    {
17
        $span = Span::getCurrent();
18
        $scope = $span->activate();
19
20
        $callableConfig = Config::get('jaravel.console.tags', fn () => [
21
            'type' => 'console',
22
        ]);
23
24
        SpanTagHelper::setTags(
25
            $span,
26
            Caller::call($callableConfig, [$event->command, $event->exitCode, $event->input, $event->output])
27
        );
28
29
        $span->end();
30
        $scope->detach();
31
    }
32
}
33