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.

ClientIdSession::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace ProtoneMedia\AnalyticsEventTracking\Http;
4
5
use Illuminate\Session\Store;
6
use Illuminate\Support\Str;
7
8
class ClientIdSession implements ClientIdRepository
9
{
10
    private Store $session;
11
    private string $key;
12
13
    public function __construct(Store $session, string $key)
14
    {
15
        $this->session = $session;
16
        $this->key     = $key;
17
    }
18
19
    /**
20
     * Stores the Client ID in the session.
21
     */
22
    public function update(string $clientId): void
23
    {
24
        $this->session->put($this->key, $clientId);
25
    }
26
27
    /**
28
     * Gets the Client ID from the session or generates one.
29
     */
30
    public function get(): ?string
31
    {
32
        return $this->session->get($this->key, fn () => $this->generateId());
33
    }
34
35
    /**
36
     * Generates a UUID and stores it in the session.
37
     */
38
    private function generateId(): string
39
    {
40
        return tap(Str::uuid(), fn ($id) => $this->update($id));
41
    }
42
}
43