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.

AuthHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 68
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A resume() 0 5 1
A process() 0 8 1
1
<?php
2
/**
3
 * Authentication Handler
4
 *
5
 * PHP version 7
6
 *
7
 * Copyright (C) 2019 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Middleware
13
 * @package   Vperyod\AuthHandler
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2019 Jake Johns
16
 * @license   http://jnj.mit-license.org/2019 MIT License
17
 * @link      https://github.com/vperyod/vperyod.auth-handler
18
 */
19
20
namespace Vperyod\AuthHandler;
21
22
use Psr\Http\Message\ResponseInterface as Response;
23
use Psr\Http\Message\ServerRequestInterface as Request;
24
use Psr\Http\Server\MiddlewareInterface;
25
use Psr\Http\Server\RequestHandlerInterface as Handler;
26
27
use Aura\Auth\Auth;
28
use Aura\Auth\Service\ResumeService as Resume;
29
30
/**
31
 * AuthHandler
32
 *
33
 * @category Middleware
34
 * @package  Vperyod\AuthHandler
35
 * @author   Jake Johns <[email protected]>
36
 * @license  http://jnj.mit-license.org/2019 MIT License
37
 * @link     https://github.com/vperyod/vperyod.auth-handler
38
 */
39
class AuthHandler implements MiddlewareInterface
40
{
41
    use AuthRequestAwareTrait;
42
43
    /**
44
     * Resume
45
     *
46
     * @var Resume
47
     *
48
     * @access protected
49
     */
50
    protected $resume;
51
52
    /**
53
     * Auth
54
     *
55
     * @var Auth
56
     *
57
     * @access protected
58
     */
59
    protected $auth;
60
61
    /**
62
     * __construct
63
     *
64
     * @param Auth   $auth   Aura\Auth current user representation
65
     * @param Resume $resume Aura\Auth Resume service
66
     *
67 1
     * @access public
68
     */
69 1
    public function __construct(Auth $auth, Resume $resume)
70 1
    {
71 1
        $this->auth   = $auth;
72
        $this->resume = $resume;
73
    }
74
75
    /**
76
     * Resume
77
     *
78
     * @return Auth
79
     *
80 1
     * @access protected
81
     */
82 1
    protected function resume() : Auth
83 1
    {
84
        $this->resume->resume($this->auth);
85
        return $this->auth;
86
    }
87
88
    /**
89
     * Resumes Authenticated Session
90
     *
91
     * @param Request  $request  PSR7 HTTP Request
92
     * @param Handler  $handler  Next handler 
93
     *
94
     * @return Response
95
     *
96
     * @access public
97 1
     */
98
    public function process(Request $request, Handler $handler): Response
99 1
    {
100 1
        $request = $request->withAttribute(
101 1
            $this->authAttribute,
102 1
            $this->resume()
103 1
        );
104
        return $handler->handle($request);
105
    }
106
}
107