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 — feature/tweak ( 28e05b )
by jake
02:03
created

Storage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 6 1
A newMessenger() 0 7 1
A getCurrent() 0 8 2
A getSegment() 0 4 1
1
<?php
2
// @codingStandardsIgnoreFile
3
4
namespace Jnjxp\Molniya\Session;
5
6
use Jnjxp\Molniya\StorageInterface;
7
use Jnjxp\Molniya\Messenger;
8
use Psr\Http\Message\ServerRequestInterface as Request;
9
use Vperyod\SessionHandler\SessionAwareTrait;
10
11
class Storage implements StorageInterface
12
{
13
    use SessionAwareTrait;
14
15
    const SEGMENT = self::class;
16
    const MESSAGE_KEY = self::class . '::MESSAGE_KEY';
17
18
    protected $current;
19
20
    public function read(Request $request) : void
21
    {
22
        $segment = $this->getSegment($request);
23
        $current = $segment->getFlash(self::MESSAGE_KEY, null);
24
        $this->current = $current ?? new Messenger\Messenger;
25
    }
26
27
    public function newMessenger(Request $request) : Messenger\MessengerInterface
28
    {
29
        $segment   = $this->getSegment($request);
30
        $messenger = new Messenger\Messenger;
31
        $segment->setFlash(self::MESSAGE_KEY, $messenger);
32
        return $messenger;
33
    }
34
35
    public function getCurrent() : Messenger\MessengerInterface
36
    {
37
        if (! $this->current) {
38
            throw new \Exception('No current!');
39
        }
40
41
        return $this->current;
42
    }
43
44
    public function getSegment(Request $request)
45
    {
46
        return $this->getSessionSegment($request, self::SEGMENT);
47
    }
48
49
50
}
51