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 Failed
Push — v0 ( 55f3d4...3235c1 )
by Jason
10:26
created

Allow   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 26 4
1
<?php
2
3
namespace JDesrosiers\Silex\Provider;
4
5
use Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
9
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
10
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
11
12
class Allow
13
{
14
    public function __invoke(Request $request, Response $response, Application $app)
15
    {
16
        $requestMethod = $app["request_context"]->getMethod();
17
        $app["request_context"]->setMethod("NOTAMETHOD");
18
19
        try {
20
            $app["url_matcher"]->match($request->getPathInfo());
21
            $allow = []; // Should never get here
22
        } catch (MethodNotAllowedException $e) {
23
            $allow = array_filter($e->getAllowedMethods(), function ($method) {
24
                return $method != "OPTIONS";
25
            });
26
        } catch (ResourceNotFoundException $e) {
27
            $allow = []; // Should never get here
28
        }
29
30
        $app["request_context"]->setMethod($requestMethod);
31
32
        if (count($allow) === 0) {
33
            throw new NotFoundHttpException();
34
        }
35
36
        $response->headers->set("Allow", implode(",", $allow));
37
38
        return $response;
39
    }
40
}
41