GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DispatchAnalyticsJob   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
A __construct() 0 3 1
A userId() 0 7 2
1
<?php
2
3
namespace ProtoneMedia\AnalyticsEventTracking\Listeners;
4
5
use Illuminate\Queue\InteractsWithQueue;
6
use Illuminate\Support\Facades\Auth;
7
use ProtoneMedia\AnalyticsEventTracking\Http\ClientIdRepository;
8
use ProtoneMedia\AnalyticsEventTracking\Jobs\SendEventToAnalytics;
9
10
class DispatchAnalyticsJob
11
{
12
    use InteractsWithQueue;
13
14
    public ClientIdRepository $clientIdRepository;
15
16
    public function __construct(ClientIdRepository $clientIdRepository)
17
    {
18
        $this->clientIdRepository = $clientIdRepository;
19
    }
20
21
    /**
22
     * Gets the Client ID from the repository and dispatched the event
23
     */
24
    public function handle($event): void
25
    {
26
        $job = new SendEventToAnalytics($event, $this->clientIdRepository->get(), $this->userId());
27
28
        if ($queueName = config('analytics-event-tracking.queue_name')) {
29
            $job->onQueue($queueName);
30
        }
31
32
        dispatch($job);
33
    }
34
35
    private function userId(): ?string
36
    {
37
        if (!config('analytics-event-tracking.send_user_id')) {
38
            return null;
39
        }
40
41
        return Auth::id();
42
    }
43
}
44