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::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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