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.
Completed
Push — master ( 1be80f...2cb972 )
by Christian
06:56
created

SessionManager::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
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\Connection\Session as LastFmSession;
15
use Core23\LastFm\Connection\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
    /**
30
     * SessionManager constructor.
31
     *
32
     * @param Session $session
33
     */
34
    public function __construct(Session $session)
35
    {
36
        $this->session = $session;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function isAuthenticated(): bool
43
    {
44
        return (bool) $this->session->get(static::SESSION_LASTFM_TOKEN);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getUsername(): ?string
51
    {
52
        return $this->session->get(static::SESSION_LASTFM_NAME);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function store(SessionInterface $lastFmSession): void
59
    {
60
        $this->session->set(static::SESSION_LASTFM_NAME, $lastFmSession->getName());
61
        $this->session->set(static::SESSION_LASTFM_TOKEN, $lastFmSession->getKey());
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function clear(): void
68
    {
69
        $this->session->remove(static::SESSION_LASTFM_NAME);
70
        $this->session->remove(static::SESSION_LASTFM_TOKEN);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getSession(): ?SessionInterface
77
    {
78
        if (!$this->isAuthenticated()) {
79
            return null;
80
        }
81
82
        return new LastFmSession(
83
            $this->session->get(static::SESSION_LASTFM_NAME),
84
            $this->session->get(static::SESSION_LASTFM_TOKEN)
85
        );
86
    }
87
}
88