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.

SessionManager   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 50
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isAuthenticated() 0 4 1
A getUsername() 0 4 1
A store() 0 5 1
A clear() 0 5 1
A getSession() 0 11 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\LastFmBundle\Session;
13
14
use Core23\LastFm\Session\Session as LastFmSession;
15
use Core23\LastFm\Session\SessionInterface;
16
use Symfony\Component\HttpFoundation\Session\Session;
17
18
final class SessionManager implements SessionManagerInterface
19
{
20
    private const SESSION_LASTFM_NAME  = '_CORE23_LASTFM_NAME';
21
22
    private const SESSION_LASTFM_TOKEN = '_CORE23_LASTFM_TOKEN';
23
24
    /**
25
     * @var Session
26
     */
27
    private $session;
28
29
    public function __construct(Session $session)
30
    {
31
        $this->session = $session;
32
    }
33
34
    public function isAuthenticated(): bool
35
    {
36
        return (bool) $this->session->get(static::SESSION_LASTFM_TOKEN);
37
    }
38
39
    public function getUsername(): ?string
40
    {
41
        return $this->session->get(static::SESSION_LASTFM_NAME);
42
    }
43
44
    public function store(SessionInterface $lastFmSession): void
45
    {
46
        $this->session->set(static::SESSION_LASTFM_NAME, $lastFmSession->getName());
47
        $this->session->set(static::SESSION_LASTFM_TOKEN, $lastFmSession->getKey());
48
    }
49
50
    public function clear(): void
51
    {
52
        $this->session->remove(static::SESSION_LASTFM_NAME);
53
        $this->session->remove(static::SESSION_LASTFM_TOKEN);
54
    }
55
56
    public function getSession(): ?SessionInterface
57
    {
58
        if (!$this->isAuthenticated()) {
59
            return null;
60
        }
61
62
        return new LastFmSession(
63
            $this->session->get(static::SESSION_LASTFM_NAME),
64
            $this->session->get(static::SESSION_LASTFM_TOKEN)
65
        );
66
    }
67
}
68