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.
Test Setup Failed
Push — master ( 7189fb...894091 )
by Carsten
13:12 queued 11s
created

LogHttpStatusMiddleware::process()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 8
cts 8
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
namespace Germania\Middleware;
3
4
use Psr\Log\LoggerInterface;
5
use Psr\Log\LoggerAwareTrait;
6
use Psr\Http\Message\RequestInterface;
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use Psr\Http\Server\MiddlewareInterface;
11
12
13
14
15
16
17
/**
18
 * Writes the HTTP Response's status code and reason to a PSR-3 Logger.
19
 */
20
class LogHttpStatusMiddleware implements MiddlewareInterface
21
{
22
    use LoggerAwareTrait;
23
24
25
    /**
26 10
     * @param LoggerInterface $logger    PSR-3 Logger instance
27
     */
28 10
    public function __construct( LoggerInterface $logger )
29 10
    {
30
        $this->logger = $logger;
31
    }
32
33
34
35
    
36
    /**
37
     * PSR-15 Single Pass
38
     * 
39
     * @param  ServerRequestInterface  $request Server reuest instance
40 10
     * @param  RequestHandlerInterface $handler Request handler
41
     * @return ResponseInterface
42
     */
43 View Code Duplication
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44 10
    {
45
46
        $response = $handler->handle($request);            
47
48
        // Now that all is done,
49 10
        // concat to a string and send it to the PSR-3 Logger.
50 10
        $status = $response->getStatusCode();
51
        $reason = $response->getReasonPhrase();
52 10
53
        $msg = sprintf("%s %s", $status, $reason);
54 10
55 8
        $this->logger->info("Response", [
56 2
            'status' => $msg
57
        ]);
58 10
59
        return $response;
60
    }     
61
62
63
64
    /**
65
     * PSR-7 Double Pass
66
     * 
67
     * @param RequestInterface   $request   Request instance
68
     * @param ResponseInterface  $response  Response instance
69
     * @param callable           $next      Middelware callable
70
     *
71
     * @return ResponseInterface
72
     */
73 View Code Duplication
    public function __invoke( ServerRequestInterface $request, ResponseInterface $response, callable $next )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        // Do nothing before $next,
76
        // instead call $next first.
77
        $response = $next($request, $response);
78
79
80
        // Now that all is done,
81
        // concat to a string and send it to the PSR-3 Logger.
82
        $status = $response->getStatusCode();
83
        $reason = $response->getReasonPhrase();
84
85
        $msg = sprintf("%s %s", $status, $reason);
86
87
        $this->logger->info("Response", [
88
            'status' => $msg
89
        ]);
90
91
        return $response;
92
    }
93
94
}
95