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
Pull Request — 3.x (#2549)
by
unknown
02:15
created

Error::renderHtmlExceptionOrError()   B

Complexity

Conditions 8
Paths 33

Size

Total Lines 31

Duplication

Lines 4
Ratio 12.9 %

Importance

Changes 0
Metric Value
dl 4
loc 31
rs 8.1795
c 0
b 0
f 0
cc 8
nc 33
nop 1
1
<?php
2
/**
3
 * Slim Framework (https://slimframework.com)
4
 *
5
 * @link      https://github.com/slimphp/Slim
6
 * @copyright Copyright (c) 2011-2017 Josh Lockhart
7
 * @license   https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
8
 */
9
namespace Slim\Handlers;
10
11
use Psr\Http\Message\ResponseInterface;
12
use Psr\Http\Message\ServerRequestInterface;
13
use Slim\Http\Body;
14
use UnexpectedValueException;
15
16
/**
17
 * Default Slim application error handler
18
 *
19
 * It outputs the error message and diagnostic information in either JSON, XML,
20
 * or HTML based on the Accept header.
21
 */
22 View Code Duplication
class Error extends AbstractError
0 ignored issues
show
Duplication introduced by
This class 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...
23
{
24
    /**
25
     * Invoke error handler
26
     *
27
     * @param ServerRequestInterface $request   The most recent Request object
28
     * @param ResponseInterface      $response  The most recent Response object
29
     * @param \Exception             $exception The caught Exception object
30
     *
31
     * @return ResponseInterface
32
     * @throws UnexpectedValueException
33
     */
34
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, \Exception $exception)
35
    {
36
        $contentType = $this->determineContentType($request);
37
        switch ($contentType) {
38
            case 'application/json':
39
                $output = Render::make('JsonErrorMessage', $exception, $this->displayErrorDetails);
40
                break;
41
42
            case 'text/xml':
43
            case 'application/xml':
44
                $output = Render::make('XmlErrorMessage', $exception, $this->displayErrorDetails);
45
                break;
46
47
            case 'text/html':
48
                $output = Render::make('HtmlErrorMessage', $exception, $this->displayErrorDetails);
49
                break;
50
51
            default:
52
                throw new UnexpectedValueException('Cannot render unknown content type ' . $contentType);
53
        }
54
55
        $this->writeToErrorLog($exception);
56
57
        $body = new Body(fopen('php://temp', 'r+'));
58
        $body->write($output);
59
60
        return $response
61
                ->withStatus(500)
62
                ->withHeader('Content-type', $contentType)
63
                ->withBody($body);
64
    }
65
}
66