ConsoleCommandStartedListener   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Umbrellio\Jaravel\Listeners;
6
7
use Illuminate\Console\Events\CommandStarting;
8
use Illuminate\Support\Facades\Config as ConfigRepository;
9
use Umbrellio\Jaravel\Services\Caller;
10
use Umbrellio\Jaravel\Services\Span\SpanCreator;
11
12
class ConsoleCommandStartedListener
13
{
14
    private SpanCreator $spanCreator;
15
16
    public function __construct(SpanCreator $spanCreator)
17
    {
18
        $this->spanCreator = $spanCreator;
19
    }
20
21
    public function handle(CommandStarting $event): void
22
    {
23
        $this->spanCreator
24
            ->create(
25
                Caller::call(ConfigRepository::get('jaravel.console.span_name'), [$event->command, $event->input])
26
            )->activate();
27
    }
28
}
29